HG_TIMESTAMP_UPDATE

 

The hg_timestamp_update is a small Java program intended as an update-hook for the Mercurial (hg) Source Control Management system. Used this way, the program will set the modification-time of each updated file to that of the last revision involving the file. In other words, all the updated files would get a modification date which is the date of the revision that is updated to, or older.

 

The hg_timestamp_update will restore the modification-times whenever files in the repository are updated, without making any other changes to the files or to the repository. The time-stamps stored in hg's normal revision history are used. Thus, a repository does not need to be "prepared" in any way in order to work with hg_timestamp_update. At any time hg_timestamp_update can be enabled/disabled for a repository, by registering/removing its update-hooks. It is recommended to install these hooks on a per-repository basis.

 

In order to get the modification-dates restored when cloning, use the following procedure:

1.     hg clone --noupdate ...

2.     register hg_timestamp_update's update-hooks in the newly cloned repository's hgrc file

3.     hg update ...

 

 

Install

 

To install the hg_timestamp_update program:

 

1.     Clone the project from bitbucket: hg clone http://bitbucket.org/esskov/hg_timestamp_update/
Or just download a copy: http://bitbucket.org/esskov/hg_timestamp_update/downloads/

2.     Copy the hg_timestamp_update.jar, the hg_timestamp_files.style and the two hg-hook scripts to the appropriate hg directories; InstallIt.bat or InstallIt.sh will normally do this for you.

3.     Then register the update and preupdate hooks in the hgrc file of each repository where you want time-stamp restoring (you can copy from hooks/hgrc).

 

The hg_timestamp_update package has been tested on Linux and Windows. A Java Runtime (JRE) package is required (i.e., the “java” command). If you don’t have Java installed already, download it here: http://www.java.com/en/ or http://java.sun.com/javase/downloads/index.jsp#jre.

 

Please note that the hg_timestamp_update software is still in alpha, use it at your own risk.

 

 

Context

 

This program could be considered a work-around for a requested (yet missing) feature of core Mercurial: http://mercurial.selenic.com/bts/issue326.

It is probably not a good idea to use this hook with time-stamp based build systems. See the Mercurial FAQ http://mercurial.selenic.com/wiki/FAQ#FAQ.2BAC8-CommonProblems.Why_is_the_modification_time_of_files_not_restored_on_checkout.3F.

An alternative approach has also been developed: http://mercurial.selenic.com/wiki/TimestampExtension.

 

 

To do

 

·        No explicit distinction is made between added/removed/updated files, when transferring the file-lists from “hg log”. Works ok in practice, however, because the "touch" function cannot create files.

·        Further test the case where the hooks are called for a merge, i.e. two parents. Should the update-hook use HG_PARENT2 after a merge?

·        For better performance, re-implement the hg_timestamp.java code in Python as an in-process hook...

 

 

Contact

 

Esben Skovenborg <esben (at) skovenborg (dot) dk>