1. Nathan Durnan
  2. TimeStampMod


TimeStampMod / README.md


About (version 0.2.1 beta)

TimestampMod is an extension for Mercurial DVCS that incorporates automatic saving and restoring of the modification times of files under version control. This extension is based on an original timestamp extension by Friedrich Kastner-Masilko face@snoopie.at hosted at https://bitbucket.org/face/timestamp.

The intent of this extension is to ease the transition from manual file system based version control into the Mercurial DVCS world. Typically, manual file system based version control methods rely on copying and synchronizing files centered around file modification timestamp information. Under any modern VCS, this timestamp information is regarded as unimportant since the VCS manages all of the revision tracking between revision records. This means that the default behavior of most VCS is to set the file modification time to the time that the file was updated by the VCS instead of the original modification time. This is a behavior that can be confusing and lead to mistrust of the VCS by new users who are not yet familiar with VCS concepts.

Incorporating automatic timestamp saving and restoring into an extension allows Mercurial to add an extra level of comfort to those users who are more familiar with manually managing their version control via traditional file management.


This extension was developed for use with the following:

Note that only Mercurial is required for the use of this extension. However, there are some peculiarities in the code specific to use with TortoiseHg. It may also be worth noting that this extension was developed and tested only on Windows XP SP3, so functionality under other operating systems my not be one-hundred-percent reliable.


Begin by downloading the TimestampMod.py file and saving it on your computer. A typical location for the file would be in an "Extensions" under the TortoiseHg program folder (usually "C:\Program Files\TortoiseHg\"). Note that this is not a default folder in the TortoiseHg installation, and must be added manually.

Then edit the appropriate configuration file:

  • The global configuration file - either:
    1. mercurial.ini for TortoiseHg, or
    2. hgrc for a stand-alone Mercurial installation.
  • Each individual repository configuration file (.hg\hgrc) where the extension is to be used.

Add an entry into the extensions section of the configuration file similar to the following::

TimestampMod = /path/to/TimestampMod.py

If using TortoiseHg, some of the hooks will need to be manually configured. Add entries into the hooks section of the configuration file (mercurial.ini) similar to the following::

post-merge.TimestampMod = python:/path/to/TimestampMod.py:Hook_Post_Merge
post-resolve.TimestampMod = python:/path/to/TimestampMod.py:Hook_Post_Resolve
post-revert.TimestampMod = python:/path/to/TimestampMod.py:Hook_Post_Revert

Nothing further is required to make the extension work. It will set up it's own hooks that will trigger during committing and updating actions automatically.

Release Notes:

These release notes will not cover every version, just tip of the repository and previous major release points.

0.2.1 (beta) - April 24, 2012

This is a major beta release. The format of the timestamp file (.hgtimestamp) has changed with this release!

  • New - Features or functionality added with this version:
  • None
  • Changed - Features or functionality modified with this version:
  • The timestamp file (.hgtimestamp) format has changed from a simple CSV file to JSON format in order to accommodate filenames with commas or other non-text characters.
  • Fixed - Issues fixed with this version:
  • Timestamps are not restored for files with a comma in the filename. This is because the timestamp file (.hgtimestamp) was previously a simple CSV file. Anything after the first comma on a line was treated as the timestamp value.
    (fixed in TimestampMod v0.2.1)
  • Known Issues - Outstanding issues with this version that have been identified but not yet addressed:
  • None

0.1.5 (beta) - February 9, 2012

This is a stable beta release that addresses several previous issues.
It is nearly ready to move from beta to production!

  • New - Features or functionality added with this version:
  • Must manually define post-merge and post-resolve hooks when used with TortoiseHg in order for timestamps to be updated correctly after a merge.
  • Individual file timestamps can be restored when using the Revert command now. This requires manually adding a post-revert hook when used with TortoiseHg.
  • Changed - Features or functionality modified with this version:
  • The timestamp file (.hgtimestamp) is now sorted alphanumerically, treating all text as lowercase. This allows for consistent ordering of the filenames in the file so that merges can be managed more easily.
  • Fixed - Issues fixed with this version:
  • Committing Subrepository fails with message "'NoneType' object has no attribute 'always'". This error was caused by a change in the Mercurial API from 1.9.x to 2.0.x.
    (fixed in TimestampMod v0.1.1)
  • Merging typically results in messy manual handling of the timestamp file (.hgtimestamp). This was caused by inconsistent ordering of the filenames in the timestamp file.
    (fixed in TimestampMod v.01.2)
  • Timestamp file (.hgtimestamp) is not always created or added correctly when a new repository is first created. This can usually be solved by trying to commit a second time.
    (fixed in TimestampMod v0.1.3)
  • File timestamps are not updated correctly after a merge. The timestamp file (.hgtimestamp) has the correct times, and timestamps will be restored after an Update, but not after a merge. Additional post-merge and post-resolve hooks were required to fix this issue.
    (fixed in TimestampMod v0.1.4)
  • 'Transplant --continue' command fails with "TypeError: cannot concatenate 'str' and 'list' objects" error message.
    (fixed in TimestampMod v0.1.5)
  • Known Issues - Outstanding issues with this version that have been identified but not yet addressed:
  • None

0.1.0 (beta) - August 9, 2011

This is an initial beta release. Undiscovered issues are expected.

!!! Known Issues !!!

Every attempt is made to keep this extension up-to-date and in working order,but there are occasional problems that arise in the development process. These issues will be noted here, and possible work-around recommendations provided if at all possible.

  • Support has been added for restoring timestamps of individual files or groups of files when the "Revert" command is used. This features works well using Mercurial directly (command-line), but does not work at all for most TortoiseHg menu command and dialogs. As of TortoiseHg 2.2.2, there is an outstanding issue with how the "Revert" command has been implemented within TortoiseHg that does not allow it to take advantage of the hooks from extensions like this one. Currently (TortoiseHg 2.2.2), the only command that seems to work from TortoiseHg is the Windows Explorer context menu "TortiseHg -> Revert Files..." item.
  • Because the timestamp record file is modified on every commit, there are nearly always merge conflicts with the timestamp file. Most of the time, these are trivial and can be resolved with a simple "Tool Resolve" option. Manually resolving the differences is not too difficult either. Just keep in mind that a larger timestamp number means a newer timestamp. This issue can affect any commands that involve merging such as graft or import (when dealing with patches). No further work will be done on this issue. After spending much time imagining how this could be automated, it was decided that it is best left to the user to determine the most appropriate timestamps to keep when merging the timestamp file.

Further Reading

If you are not familiar with installing extensions for Mercurial/TortoiseHg, it is strongly recommended to review the UsingExtensions wiki page from Mercurial. The wiki documents the basic use of extensions, as well as provides links to additional extensions that you may find useful.

Open Source Project Reference

Project statistics for this extension are tracked using the Ohloh public open-source software directory. Please reference the following for this extension and its dependencies: