About (version 0.3.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 hosted at

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:

  • TortoiseHg 2.1 (or later)
    • Required Mercurial and Python libraries
      are already included with TortoiseHg.
  • Mercurial 1.9 (or later)
    • Python 2.6 (or later) must be present when using
      a stand-alone (command line) Mercurial installation.

Note that only Mercurial is required for the use of this extension. However, there are some configuration requirements that are specific to either command line Mercurial or TortoiseHg.

Also note that forward development of this extension is not guaranteed to remain backward-compatible with older Mercurial/Python/TortoiseHg versions. Some changes in Mercurial and TortoiseHg may break the backwards-compatibility of this extension.

Latest known compatible versions:

  • TortoiseHg 4.3
  • Mercurial 4.3
  • Python 2.7

It may also be worth noting that this extension was originally developed and tested on Windows XP SP3 (32-bit), and Windows 7 Professional (64-bit). It has been confirmed to work on Linux Ubuntu 12.04. Functionality under other operating systems my not be one-hundred-percent reliable.


1. Download the Extension

Download the 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.

2. Configure the Extension

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 = C:\Program Files\TortoiseHg\Extensions\

Adjust the path as needed to match your installation.

3. Special Configuration for TortoiseHg

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:C:\Program Files\TortoiseHg\Extensions\
post-resolve.TimestampMod = python:C:\Program Files\TortoiseHg\Extensions\
post-revert.TimestampMod = python:C:\Program Files\TortoiseHg\Extensions\

Adjust the paths as needed to match your installation.

4. Additional Steps for Command Line Mercurial

When this extension is used with the command line Mercurial package (installed separately from TortoiseHg), an additional Python package must be referenced. The Python package that is distributed with the command line Mercurial installation (as of version 2.1.2) is missing some of the library elements needed by this extension. The package that is distributed with TortoiseHg (version 2.0.5+) is sufficient, or a full Python package may be installed.

Download and install at least Python 2.6.6 from:

After installing TortoiseHg or Python, the extension must be informed of the Python library path so it can access the required library components. Add a paths section and entry to the configuration file (mercurial.ini or hgrc) similar to the following:

PythonLibPath = C:\Python26\lib


PythonLibPath = C:\Program Files\TortoiseHg\

Adjust the path as needed to match your installation.

5. Testing the Installation

Open any command prompt and issue the following command to check of the extension is properly installed:

hg help timestamp_mod

If the installation was installed correctly, the output should be similar to the following:

C:\>hg help timestamp_mod
hg timestamp_mod [-s | -r]

C:\Program Files\TortoiseHg\Extensions\
  (Version 0.3.1)

Save or restore file modification times.


 -s --save    save modification times
 -r --restore restore modification times

use "hg -v help timestamp_mod" to show more info


Nothing further is required to make the extension work. It will automatically save and restore timestamps for all files tracked in the repository during commit and update actions.

Release Notes:

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

0.3.1 (beta) - October 24, 2017

This is a bug-fix release.

  • Fixed - Issues fixed with this version:
    • Timestamp file error when reverting from command-line within a subdirectory. (fixed in TimestampMod v0.3.1)
    • Updating is slow for large repositories that have many ingored files/folders. (fixed in TimestampMod v0.3.1)
    • File cahnge without size change not detected acter update with "always merge" option. (fixed in TimestampMod v.03.1)
    • Extension broken with Mercurial 4.3+. (fixed in TimestampMod v.03.1)

0.3.0 (beta) - March 9, 2017

This is a compatibility / bug-fix release.

  • Fixed - Issues fixed with this version:
    • Warning message: missing attribute 'norepo' (fixed in TimestampMod v0.3.0) NOTE: This issue started with Mercurial 3.8 - fix may not be backwards compatible.
    • Error message: AttributeError: 'function' object has no attribute 'norepo' (fixed in TimestampMod v0.3.0) NOTE: This issue started with Mercurial 4.1 - fix may not be backwards compatible.

0.2.9 (beta) - March 30, 2016

This is a bug-fix release.

  • Fixed - Issues fixed with this version:
    • Warning message on Commit and Update commands: repo.parents() is deprecated (fixed in TimestampMod v0.2.9) NOTE: This issue started with Mercurial 3.7 - fix may not be backwards compatible.
    • Exception message on Status and Merge commands: 'mergestate' object has no attribute '\_state' (fixed in TimestampMod v0.2.9) NOTE: This issue started with Mercurial 3.7 - fix may not be backwards compatible.

0.2.8 (beta) - October 21, 2013

This is a bug-fix release.

  • Fixed - Issues fixed with this version:
    • Committing with --subrepos option resulted in error message "'NoneType' object has no attribute 'files'" (fixed in TimestampMod v0.2.8)
    • The timestamp file was the only file committed when using commit without file specification or patters. It appeared to only affect Linux users. The internal match list was being incorrectly populated - it should have remained empty. (fixed in TimestampMod v0.2.7)

0.2.6 (beta) - July 11, 2012

This is a bug-fix release.

  • Changed - Features or functionality modified with this version:
    • The extension will abort running the Post-Merge and Post-Resolve hooks until there are no unresolved files. Command line merge tools can leave extra lines in unresolved files to help with manual merging. This makes it impossible for the extension to read the JSON timestamp file. Since unresolved files indicate an intermediate merge state, reapplying the timestamps to the unresolved state would likely be incorrect in the first place.
      (changed in TimestampMod v0.2.3)
    • The extension will no longer report a missing timestamp record file (.hgtimestamp) as an error when creating a new repository. The error message was misleading - the missing file really is a low-priority condition. The extension now quietly deals with the missing file without creating panic for the user.
      (changed in TimestampMod v0.2.6)
  • Fixed - Issues fixed with this version:
    • A compatibility issue with the command line Mercurial package was fixed. The Python library distributed with the command line Mercurial package does not include the JSON module! A separate Python installation is required for use with the command line Mercurial package. The extension can now reference an external Python library to pick up the components it needs that may be missing from Mercurial or TortoiseHg native Python libraries.
      (fixed in TimestampMod v0.2.3)
    • Timestamps were not restored when hg revert was used with a folder name. The extension was attempting to treat the folder name as a reverted file, but could not find the timestamp data for it. The extension now distinguishes between reverting files and reverting folders and applies timestamps to the files within a reverted folder.
      (fixed in TimestampMod v0.2.4)
    • Exception error occurred when using TimestampMod with older versions of MQ patch queue extension. The MQ qrefresh was calling commit with match.files() as set() instead of list(). The TimestampMod extension now coerces the match.files() object to a list to avoid this issue.
      (fixed in TimestampMod v0.2.5)
    • Save Timestamp for Committed Files ONLY. When committing specific files, the extension was saving the timestamps of ALL files tracked in the repository even if they are not included in the commit. It should only be saving timestamps for files that have been included in the commit.
      (fixed in TimestampMod v0.2.6)
    • Error occurred when trying to update to a revision that had no files in the Working Directory. The extension did not find any timestamp records in the JSON file, so it was attempting to open it as a CSV file. It now recognizes the lack of timestamp records as an empty Working Directory.
      (fixed in TimestampMod v0.2.6)
    • Filenames with international characters in them (Japanese CP932 for example) were not supported. Reading the timestamp file as JSON would fail and attempt to read it as CSV (and still fail).
      (fixed in TimestampMod v0.2.6)

0.2.2 (beta) - April 26, 2012

This is a feature change beta release. The format of the timestamp file (.hgtimestamp) has changed with this release in order to be more forward-compatible.

  • Changed - Features or functionality modified with this version:
    • The timestamp file (.hgtimestamp) format has been modified to allow better forward-compatibility. This mean that from this version and those following, any additional modifications to the timestamp file should not break compatibility with previous versions (at least back to v0.2.2).
      (changed in TimestampMod v0.2.2)
    • 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.
      (changed in TimestampMod v0.2.1)
  • 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)

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)

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.

  • 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. The timestamps are stored as Unix Epoch values, so they may be manually decoded/encoded if needed as well. 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: