TimeStampMod /

Filename Size Date modified Message
Tests
28 B
1.4 KB
599 B
15.0 KB
1.8 KB
184.9 KB
38.4 KB

TimestampMod

About (version 0.2.6 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 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.

Requirements

This extension was developed for use with the following:

  • TortoiseHg 2.0.4 (or later)
    • Required Mercurial and Python libraries
      are already included with TortoiseHg.
  • Mercurial 1.8.3 (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.

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.


Installation

1. Download the Extension

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

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:

[extensions]
TimestampMod = C:\Program Files\TortoiseHg\Extensions\TimestampMod.py

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:

[hooks]
post-merge.TimestampMod = python:C:\Program Files\TortoiseHg\Extensions\TimestampMod.py:Hook_Post_Merge
post-resolve.TimestampMod = python:C:\Program Files\TortoiseHg\Extensions\TimestampMod.py:Hook_Post_Resolve
post-revert.TimestampMod = python:C:\Program Files\TortoiseHg\Extensions\TimestampMod.py:Hook_Post_Revert

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:

http://python.org/download/releases/2.6.6/

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:

[paths]
PythonLibPath = C:\Python26\lib

or

[paths]
PythonLibPath = C:\Program Files\TortoiseHg\library.zip

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\TimestampMod.py
  (Version 0.2.4)

Save or restore file modification times.

options:

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

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

C:\>

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.2.6 (beta) - July 11, 2012

This is a bug-fix release.
ALL USERS OF v0.2.x ARE URGED TO UPDATE TO THIS VERSION!

  • 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 emtpy 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.

  • 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. 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:

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.