Commits

Anonymous committed 5266963 Merge

Merge with development (release 0.2.7)
Picking up BBI#40 - Linux Compatability

Comments (0)

Files changed (6)

 {
-"Version": "0.2.4",
+"Version": "0.2.6",
 "FileData":{
 ".hgignore": {"timestamp": 1336516662.38},
 ".hgtags": {"timestamp": 1342195170.14},
-"README.md": {"timestamp": 1342031813.02},
-"Tests/BBI36_CheckTimestampFileExists_Test.bat": {"timestamp": 1342032060.52},
-"Tests/BBI37_SaveOnlyCommittedTimestamps_Test.bat": {"timestamp": 1342032121.8},
+"README.md": {"timestamp": 1363201331.4},
+"Tests/BBI36_CheckTimestampFileExists_Test.bat": {"timestamp": 1363119528.84},
+"Tests/BBI37_SaveOnlyCommittedTimestamps_Test.bat": {"timestamp": 1363121220.92},
 "Tests/BBI38_EmptyUpdate_Test.bat": {"timestamp": 1341604677.09},
+"Tests/BBI40_LINUX_TEST.bat": {"timestamp": 1363121154.72},
 "TimeStampMod.png": {"timestamp": 1305052883.0},
-"TimestampMod.py": {"timestamp": 1342194746.52},
+"TimestampMod.py": {"timestamp": 1363200179.76},
 "TimeStampMod.xmind": {"timestamp": 1306451621.66},
 "TimestampMod_LastRecord": {"timestamp": 0}
 }
 TimestampMod
 ============
-About (version 0.2.6 beta)
+About (version 0.2.7 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](mailto:face@snoopie.at) hosted at [https://bitbucket.org/face/timestamp][ts].
 
 
 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.
+It may also be worth noting that this extension was 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.
 
 
 - - -
   
 [pydl]: 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:
+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
 --------------
 These release notes will not cover every version, just tip of the repository and previous major release points.
 
+### __0.2.7 (beta)__ - _March 13, 2013_
+This is a bug-fix release.  
+**ALL USERS OF v0.2.x ARE URGED TO UPDATE TO THIS VERSION!**
+
++ __Fixed__ - Issues fixed with this version:
+    * 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.
+
 ### __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.  
 + __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.  
+    * 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.  
+    * 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)_

Tests/BBI36_CheckTimestampFileExists_Test.bat

 hg add abc.txt
 echo hg commit -m "abc"
 hg commit -m "abc"
+echo.
+echo.
+echo hg status
+hg status
+echo.
 echo --------------------------------------------
 echo CHECK: no error message should be displayed.
+echo `hg status` result should be empty
 echo ============================================
 pause
 echo.
 hg add abc.txt
 echo hg commit -m "abc" --debug
 hg commit -m "abc" --debug
+echo.
+echo.
+echo hg status
+hg status
+echo.
 echo --------------------------------------------
 echo CHECK: no error message should be displayed,
-echo        just a simple notification message.
+echo        just notification messages.
+echo `hg status` result should be empty
 echo ============================================
 pause

Tests/BBI37_SaveOnlyCommittedTimestamps_Test.bat

 echo Timestamps after committing only bcd.txt
 type .hgtimestamp
 echo.
+echo.
+echo hg status
+hg status
+echo.
 echo ------------------------------------------------------
 echo CHECK: ONLY the bcd.txt timestamp should have changed.
+echo `hg status` result should show abc.txt as Modified (M)
 echo ======================================================
 pause
 echo.
 echo Timestamps after committing with no Match
 type .hgtimestamp
 echo.
+echo.
+echo hg status
+hg status
+echo.
 echo -------------------------------------------
 echo CHECK: BOTH timestamps should have changed.
+echo `hg status` result should be empty
 echo ===========================================
 pause

Tests/BBI40_LINUX_TEST.bat

+::------------------------------------------------------------------------------
+:: Tests for BitBucket Issue #40 - Linux Compatability.
+:: This is a simple functional test to ensure the extension commits timestamps
+:: and modified/added files correctly.  This is similar to the test for BBI#36.
+::------------------------------------------------------------------------------
+:: This test-script creates a temporary test repository,
+:: creates and addes a single file, and commits the file.
+::------------------------------------------------------------------------------
+@echo off
+echo.
+echo ===========================================
+echo Test #1 - New Repository - Commit Normally.
+echo.
+echo ----------
+echo Initializing Test Repository...
+if exist testrepo rmdir /S /Q testrepo
+mkdir testrepo
+cd testrepo
+hg init
+echo Create file (abc.txt)
+echo "abc" > abc.txt
+hg add abc.txt
+echo hg commit -m "abc"
+hg commit -m "abc"
+echo.
+echo --------------------------------------------
+echo CHECK: no error message should be displayed.
+echo ============================================
+pause
+echo.
+echo hg status
+hg status
+echo.
+echo hg manifest
+hg manifest
+echo.
+echo.
+echo cat .hgtimestamp
+cat .hgtimestamp
+echo.
+echo --------------------------------------------
+echo CHECK: 
+echo   `hg status` result should be empty
+echo   Manifest should contain ".hgtimestamp" and "testfile"
+echo   .hgtimestamp should contain "testfile" entry
+echo ============================================
+pause
 # end help text
 #=============================================================================
 # TimestampMod.py - Automatically save and restore file modification times 
-File_Version = '0.2.6'  # Version number definition
+File_Version = '0.2.7'  # Version number definition
 # --> !!BETA RELEASE!!! <--
-# Copyright 2011-2012 Nathan Durnan <nedmech@gmail.com>
+# Copyright 2011-2013 Nathan Durnan <nedmech@gmail.com>
 #
 # Based on timestamp extension by Friedrich Kastner-Masilko <face@snoopie.at>
 # This extension differs from the original in that the original only managed
 #	recorded and restored during commit, update, revert, etc. operations.
 #
 # Development information:
-#	Mercurial Version:  1.8.3 - 2.2.2 (from TortoiseHg package)
-#	Python Version:     2.6.6 (from TortoiseHg package)
-#	TortoiseHg Version: 2.0.4 - 2.4.1
+#	Mercurial Version:  1.8.3 - 2.5.2 (from TortoiseHg package)
+#	Python Version:     2.6.6 - 2.7.3 (from TortoiseHg package)
+#	TortoiseHg Version: 2.0.4 - 2.7.1
 #=============================================================================
 
 #=============================================================================
 		force=False, 
 		editor=False, 
 		extra={}):
-	repo.ui.note('TimestampMod|Wrap_Commit accessed!\n')
+	repo.ui.note('______\nTimestampMod|Wrap_Commit accessed!\n')
 	#Check for a merge-commit. 
 	#  Don't run timestamp code until merge is complete.
 	if (len(repo.parents()) > 1):
 			)
 	else:
 		# Make sure the match object is created.
-		if not match:
+		if not isinstance(match, matchmod.match):
 			repo.ui.debug('Empty match: Must create!\n')
 			#create an empty match object
-			match = matchmod.always(repo.root, '')
+			localmatch = matchmod.always(repo.root, '')
 		else:
-			pass
+			# Make sure match.files is a list, not a set or other type.
+			if not isinstance(match.files(), list):
+				#coerce files() to a list object.
+				match._files = list(match.files())
+			#end of check for list type
+			localmatch = match
 		# End of check for non-existent match object.
-		# Make sure match.files is a list, not a set or other type.
-		if not isinstance(match.files(), list):
-			#coerce files() to a list object.
-			match._files = list(match.files())
-		#end of check for list type
-		myList_Match = match.files() 
 		#don't add timestamp file here, it will be added later.
 		timestamp_mod(
 			repo.ui, 
 			**dict({
 				'save': True, 
 				'restore': None, 
-				'match': myList_Match
+				'match': localmatch.files()
 				})
 			)
-		# Make sure record file is part of repository and commit. 
-		if not (File_TimestampRecords in repo.dirstate):
-			repo.ui.debug(
-				'Wrap_Commit: ', 
-				File_TimestampRecords, 
-				' not in repo.dirstate  Adding...\n'
-				)
-			#\/ same method used for adding '.hgtags' file in localrepo.py
-			repo[None].add([File_TimestampRecords]) 
-		#end of check for record file in repository.
-		#Update match fileset for use under TortoiseHg.
-		#  TortoiseHg doesn't seem to catch the updated file
-		#  unless it is manually added to the match fileset.
-		if (File_TimestampRecords in match.files()):
-			# Don't need to do anything if record file already in commit.
-			repo.ui.debug(
-				'Wrap_Commit: ', 
-				File_TimestampRecords, 
-				' already in match\n'
-				)
-			pass
-		else:
-			# Add the record file to the match object.
+		#Check for match conditions.
+		if ((match is None) or 
+			(not match.files())):
+			#Similar to test for generic commit in hgext\largefiles\reposetup.py
+			repo.ui.debug('Wrap_Commit: no match specified\n')
+		elif (File_TimestampRecords not in match.files()):
+			#Record file must get added to list if any match is specified.
 			match.files().append(File_TimestampRecords)
-		# end of check for record file.
+		# end of check match conditions
 		repo.ui.debug('Match Files: ', str(match.files()), '\n')
 	#end of check for merge-commit.
-	repo.ui.note('TimestampMod|Wrap_Commit finished!\n')
+	repo.ui.note('TimestampMod|Wrap_Commit finished!\n______\n')
 	return repo.timestamp_origcommit(
 			text, 
 			user, 
 #-----------------------------------------------------------------------------
 # Summary: These functions are intended to be triggered by the hooks defined
 #	either by Mercurial or in the configuration files.
-# NOTES: The pre-** hooks are the only ones that does not function properly
+# NOTES: The pre-** hooks are the only ones that do not function properly
 #	under the TortoiseHg GUI.  All the hooks work from command-line.
 #=============================================================================
 # Hook_Pre_Commit is depreciated in favor of Wrap_Commit method
 	kwargs['pats'].append(File_TimestampRecords)
 ''' # Hook_Pre_Commit is depreciated
 def Hook_Post_Status(repo, **kwargs):
-	repo.ui.note('TimestampMod|Post-Status Hook accessed!\n')
+	repo.ui.note('______\nTimestampMod|Post-Status Hook accessed!\n')
 	myUnresolved = _check_Merge_unresolved(repo)
 	if myUnresolved:
 		repo.ui.note(
 			'restore': None
 			})
 		)
+	repo.ui.note('TimestampMod|Post-Status Hook finished!\n______\n')
 
 def Hook_Update(repo, **kwargs):
-	repo.ui.note('TimestampMod|Hook_Update accessed!\n')
+	repo.ui.note('______\nTimestampMod|Hook_Update accessed!\n')
 	if (len(repo.parents()) > 1):
 		repo.ui.note(
 			'TimestampMod|Hook_Update aborted', 
 				})
 			)
 	#end of check for merging.
+	repo.ui.note('TimestampMod|Hook_Update finished!\n______\n')
 
 def Hook_Post_Merge(repo, **kwargs):
-	repo.ui.note('TimestampMod|Post-Merge Hook accessed!\n')
+	repo.ui.note('______\nTimestampMod|Post-Merge Hook accessed!\n')
 	myUnresolved = _check_Merge_unresolved(repo)
 	if myUnresolved:
 		repo.ui.note(
 				})
 			)
 	#check for preview option.
+	repo.ui.note('TimestampMod|Post-Merge Hook finished!\n______\n')
 
 def Hook_Post_Resolve(repo, **kwargs):
-	repo.ui.note('TimestampMod|Post-Resolve Hook accessed!\n')
+	repo.ui.note('______\nTimestampMod|Post-Resolve Hook accessed!\n')
 	myUnresolved = _check_Merge_unresolved(repo)
 	if myUnresolved:
 		repo.ui.note(
 				})
 			)
 	#end of check for timestamp file resolve.
+	repo.ui.note('TimestampMod|Post-Resolve Hook finished!\n______\n')
 
 def Hook_Post_Revert(repo, **kwargs):
 	'''NOTE: TortoiseHg Incompatibility Issue!
 	is on their list of items that need fixed:
 	https://bitbucket.org/tortoisehg/thg/issue/1347/add-support-for-pre-and-post-hooks
 	'''
-	repo.ui.note('TimestampMod|Post-Revert Hook accessed!\n')
+	repo.ui.note('______\nTimestampMod|Post-Revert Hook accessed!\n')
 	bDryRun = False #starting value
 	bAll = False #starting value
 	listExclude = list()
 			'error deleting temporary timestamp file!\n'
 			)
 	#end of deleting temporary timestamp file.
+	repo.ui.note('TimestampMod|Post-Revert Hook finished!\n______\n')
 #_ end of Hook Functions _____________________________________________________
 
 
 #=============================================================================
 def timestamp_mod(ui, repo, **kwargs):
 	'''Save or restore file modification times.'''
-	ui.note('Executing timestamp_mod function\n')
+	repo.ui.note('Executing timestamp_mod function\n')
 	# Retrieve Repository file list contents.
 	myChangedList = list()
 	myDroppedList = list()
 	myMatchList = list()
 	if ('match' in kwargs):
-		ui.debug('-----\nmatch: ', str(kwargs['match']), '\n')
+		repo.ui.debug('-----\nmatch: ', str(kwargs['match']), '\n')
 		myMatchList = kwargs['match']
 	else:
-		ui.debug('-----\nmatch argument not specified\n')
+		repo.ui.debug('-----\nmatch argument not specified\n')
 	# end of check for match argument'''
 	# Build initial file lists from the repository contents.
 	myChangedList, myDroppedList = \
 		OUT_TimeStamp_dict
 		):
 	'''Build lists of files from the repository status contents.'''
-	repo.ui.debug(
-		'______\n', 
-		'Generating file list from repo...\n', 
-		'------\n'
-		)
+	repo.ui.debug('------ Generating file list from repo...\n')
 	# Establish category lists from repository status.
 	modified, added, removed, deleted, unknown, ignored, clean = \
 		repo.status(ignored=True, clean=True, unknown=True)
 		repo.ui.debug('*** Exception: ', str(sys.exc_info()), '  ***\n')
 		return True	# set return flag on error.
 	# end of opening record file.
-	repo.ui.debug(
-		'______\n', 
-		'Retrieving timestamps from record file:\n', 
-		'------\n'
-		)
+	repo.ui.debug('------ Retrieving timestamps from record file:\n')
 	for myLine in myTimeStampRecordsFile.readlines():
 		# Read the data from the line. 
 		# (CSV format: [FileName],[ModificationTime])
 		repo.ui.debug('*** Exception: ', str(sys.exc_info()), '  ***\n')
 		return True	# set return flag on error.
 	# end of opening record file.
-	repo.ui.debug(
-		'______\n', 
-		'Retrieving timestamps from JSON record file:\n', 
-		'------\n'
-		)
+	repo.ui.debug('------ Retrieving timestamps from JSON record file:\n')
 	# Read in file content into local string.
 	s_Content = myTimeStampJSONFile.read()
 	myTimeStampJSONFile.close()
 		try:
 			myData = json.loads(unicode(s_Content, testEncoding))
 		except:
-			repo.ui.debug( \
-				'*** ', testEncoding, ' Exception: \n', \
-				str(sys.exc_info()), '\n***\n')
+			repo.ui.debug( 
+				'*** ', testEncoding, ' Exception: \n', 
+				str(sys.exc_info()), '\n***\n'
+				)
 			#move on to check next encoding.
 			continue
 		else:
 		INOUT_TimeStamp_dict
 		):
 	'''Save File Modification Timestamps to JSON record file.'''
-	repo.ui.note(
-		'______\n', 
-		'Saving timestamps to JSON file...\n', 
-		'------\n'
-		)
+	repo.ui.note('------ Saving timestamps to JSON file...\n')
 	# Remove the record file from the list.
 	#	It causes confusion and difficulty during merge.
 	if IN_TimestampFileName in INOUT_TimeStamp_dict:
 		if (s_fileName in IN_ChangedList) or (f_fileModTime<=0):
 			# Make sure to only save new file timestamps if they have  
 			# been included in the commit (will be in the match list).
-			if (f_fileModTime>0) and \
-					(len(IN_MatchList)>0) and \
-					(s_fileName not in IN_MatchList):
+			if ((f_fileModTime>0) and 
+					(len(IN_MatchList)>0) and 
+					(s_fileName not in IN_MatchList)):
 				# Do not save new timestamp if file is not in match list.
 				pass
 			else: 
 		)
 	# Make sure to close the file!
 	myTimeStampJSONFile.close()
+	#Make sure the record file is in the repository.
+	if not (IN_TimestampFileName in repo.dirstate):
+		repo.ui.debug(
+			'_save_TimestampsJSON: ', 
+			IN_TimestampFileName, 
+			' not in repo.dirstate  Adding...\n'
+			)
+		#\/ same method used for adding '.hgtags' file in localrepo.py
+		repo[None].add([IN_TimestampFileName]) 
+		repo.dirstate.rebuild #to pick up new record file state.
+	#end of check for record file in repository.
 #_ end of _save_TimestampsJSON _______________________________________________
 
 
 #=============================================================================
 def _restore_Timestamps(repo, IN_TimeStamp_dict):
 	'''Restore File Modification Timestamps from record file.'''
-	repo.ui.note('______\nRestoring timestamps...\n------\n')
+	repo.ui.note('------ Restoring timestamps...\n')
 	for s_fileName, f_fileModTime in IN_TimeStamp_dict.items():
 		# Check for valid timestamp.
 		if (f_fileModTime>0):
 #=============================================================================
 def _display_Timestamps(repo, myTimeStamp_dict):
 	'''Display File Timestamps currently recorded.'''
-	repo.ui.note('______\nDisplaying timestamps...\n------\n')
+	repo.ui.note('------ Displaying timestamps...\n')
 	for s_fileName, f_fileModTime in myTimeStamp_dict.items():
 		# Check for valid timestamp
 		if (f_fileModTime>0):