Nathan Durnan  committed 92ec281 Merge

Merge with Release 0.2.4
(Fixes reverting folder contents)

  • Participants
  • Parent commits 3f189de, aff4c33
  • Branches default
  • Tags Version 0.2.4

Comments (0)

Files changed (3)

File .hgtimestamp

-"Version": "0.2.3",
+"Version": "0.2.4",
 ".hgignore": {"timestamp": 1336516662.38},
 ".hgtags": {"timestamp": 1338442327.75},
-"": {"timestamp": 1337016337.19},
+"": {"timestamp": 1339170145.3},
 "TimeStampMod.png": {"timestamp": 1305052883.0},
-"": {"timestamp": 1338440223.52},
+"": {"timestamp": 1339114719.52},
 "TimeStampMod.xmind": {"timestamp": 1306451621.66},
 "TimestampMod_LastRecord": {"timestamp": 0}
-About (version 0.2.3 beta)
+About (version 0.2.4 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 [][ts].
 	hg timestamp_mod [-s | -r]
 	C:\Program Files\TortoiseHg\Extensions\
-	  (Version 0.2.3)
+	  (Version 0.2.4)
 	Save or restore file modification times.
 These release notes will not cover every version, just tip of the repository and previous major release points.
-### __0.2.3 (beta)__ - _May 14, 2012_
+### __0.2.4 (beta)__ - _June 7, 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)_
 + __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)_
 ### __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)_
-+ __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.  
     _(changed in TimestampMod v0.2.1)_
 + __Fixed__ - Issues fixed with this version:


 # end help text
 # - Automatically save and restore the modification times of files
-File_Version = '0.2.3'	# Version number definition
+File_Version = '0.2.4'	# Version number definition
 # --> !!BETA RELEASE!!! <--
 # Copyright 2011-2012 Nathan Durnan <>
 import sys	#requied for debugging/exception info.
 import os	#required for filesystem access methods.
+import os.path	#required for filesystem path methods.
 import time	#required for time functions.
 import json	#use JSON format for storing timestamp data in file.
 import inspect	#required for getting path/name of current code module.
+import fnmatch	#required for checking file patterns.
 from mercurial import localrepo	#required for creating a pseudo-pre-commit hook.
 from mercurial import match as matchmod	#required for "match" object in commit wrapper.
 from mercurial import merge as mergemod	#required for merge state (check unresolved)
 			kwargs['opts']['rev'] = cmdutil.finddate(repo.ui, repo, kwargs['opts']['date'])
 		#end of check for date specified.
 	#end of check for 'opts' keyword.
+	#Establish lists of potentially reverted files from repository status.
+	modified, added, removed, deleted, unknown, ignored, clean = repo.status(node2=kwargs['opts']['rev'])
+	maybeReverted = modified + added
 	#Create a temporary copy of the timestamp file from the source revision., repo, 
 		File_TimestampRecords, File_TimestampRecords, 
 		for myFile in kwargs['pats']:
 			myFileName = str(myFile).strip()
-			TimeStamp_dict[myFileName] = -1
+			if os.path.isfile(myFileName):
+				TimeStamp_dict[myFileName] = -1
+			elif os.path.isdir(myFileName):
+				#Check the potential list of reverted files against the directory path pattern.
+				for sFile in sorted(maybeReverted):
+					if fnmatch.fnmatch(sFile, (myFileName + '/*')):
+						TimeStamp_dict[sFile] = -1
+					#end of checking for matching directory path pattern
+				#end of loop through potential reverted file list
+			#end check for file or directory.
 		#end of loop through pattern list
 	#end of check for 'all' flag
 	# Retrieve existing timestamps from the record file.
 		os.unlink(repo.wjoin(File_TimestampRecords + '.revert'))
-		repo.ui.status("Post-Revert: error deleting timestamp file!\n")
+		repo.ui.status("Post-Revert: error deleting temporary timestamp file!\n")
 	#end of deleting temporary timestamp file.
 #_ end of Hook Functions ______________________________________________________