Commits

Nathan Durnan committed 685842b Merge

Merge with BBI#38 - JSON File with No Timestamps

Comments (0)

Files changed (3)

 {
-"Version": "0.2.6.0705",
+"Version": "0.2.4",
 "FileData":{
 ".hgignore": {"timestamp": 1336516662.38},
 ".hgtags": {"timestamp": 1327960909.75},
 "README.md": {"timestamp": 1341533861.92},
 "Tests/BBI36_Test.bat": {"timestamp": 1341533372.44},
+"Tests/BBI38_EmptyUpdate_Test.bat": {"timestamp": 1341604677.09},
 "Tests/TimestampMod_BBI37_Test.bat": {"timestamp": 1341343207.95},
 "TimeStampMod.png": {"timestamp": 1305052883.0},
-"TimestampMod.py": {"timestamp": 1341533391.67},
+"TimestampMod.py": {"timestamp": 1341605454.61},
 "TimeStampMod.xmind": {"timestamp": 1306451621.66},
 "TimestampMod_LastRecord": {"timestamp": 0}
 }

Tests/BBI38_EmptyUpdate_Test.bat

+::------------------------------------------------------------------------------
+:: Tests for BitBucket Issue #38 - Read JSON File with no Timestamp data.
+:: The _read_TimestampJSONRecords function fails and returns an error when 
+:: updating to a revision that has no timestamp data recorded.
+::------------------------------------------------------------------------------
+:: This test-script creates a temporary test repository,
+:: creates and addes a single file, and commits the file.
+:: The file is then removed and the removal is committed.
+:: Finally, the Working directory is updated to both revisions.
+::------------------------------------------------------------------------------
+@echo off
+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 "add abc.txt"
+hg commit -m "add abc.txt"
+echo hg remove abc.txt
+hg remove abc.txt
+echo hg commit -m "remove abc.txt"
+hg commit -m "remove abc.txt"
+echo.
+echo =============================================
+echo Test #1 - Update to Rev-0 and Rev-1 normally.
+echo.
+echo ----------
+echo hg update 0
+hg update 0
+echo.
+echo.
+echo hg update 1
+hg update 1
+echo.
+echo ----------------------------------------------
+echo CHECK: no error messages should be displayed. 
+echo It should not try to open .hgtimestamp as CSV.
+echo ==============================================
+pause
+echo.
+echo.
+echo ===============================================
+echo Test #2 - Update to Rev-0 and Rev-1 w/ --debug.
+echo.
+echo ----------
+echo hg update 0 --debug
+hg update 0 --debug
+echo.
+echo.
+echo hg update 1 --debug
+hg update 1 --debug
+echo.
+echo ---------------------------------------------
+echo CHECK: no error messages should be displayed.
+echo It should not try to open .hgtimestamp as CSV.
+echo =============================================
+pause
 # end help text
 #==============================================================================
 # TimestampMod.py - Automatically save and restore the modification times of files
-File_Version = '0.2.6.0705'	# Version number definition
+File_Version = '0.2.6.0706'	# Version number definition
 # --> !!BETA RELEASE!!! <--
 # Copyright 2011-2012 Nathan Durnan <nedmech@gmail.com>
 #
 						# end of check for per-item warning.
 					# end of check file exists in dictionary.
 				# end of loop through items.
-				if (myWarnCount >= len(myData['FileData'])):
+				if (len(myData['FileData']) <= 0):
+					# This is not an error condition.
+					# Likely just an empty working directory.
+					repo.ui.debug(IN_TimestampFileName, 
+						' contains no file records', 
+						' - Working Directory is empty?\n')
+				elif (myWarnCount >= len(myData['FileData'])):
 					repo.ui.debug('ERROR: Could not read any JSON file data from ', IN_TimestampFileName, '\n')
 					myErr = True	# Error - could not find JSON data
 				# end of check warning count.
 			else: # JSON file data is not present
 				repo.ui.debug(IN_TimestampFileName, ' does not have JSON file data.\n')
-				myErr = True	# Error - could not find JSON data
+				myErr = True	# Error - could not find JSON FileData records
 			# end of check for file data.
 		except: # report errors
 			repo.ui.debug('Error loading JSON file\n')