Commits

Nathan Durnan  committed 174f90b

Check for no entries in FileData section before testing for errors.
See Issue#38 at BitBucket.

If there are no entries in the FileData section,
then both {{{myWarnCount}}} and {{{len(myData['FileData'])}}}}
would be zero. This is not an error condition.
It just indicates that the Working Directory is empty.

  • Participants
  • Parent commits 41be561
  • Branches BBI#38 - JSON File with No Timestamps

Comments (0)

Files changed (2)

File .hgtimestamp

 "Tests/BBI38_EmptyUpdate_Test.bat": {"timestamp": 1341604677.09},
 "Tests/TimestampMod_BBI37_Test.bat": {"timestamp": 1341343207.95},
 "TimeStampMod.png": {"timestamp": 1305052883.0},
-"TimestampMod.py": {"timestamp": 1341603809.98},
+"TimestampMod.py": {"timestamp": 1341605454.61},
 "TimeStampMod.xmind": {"timestamp": 1306451621.66},
 "TimestampMod_LastRecord": {"timestamp": 0}
 }

File TimestampMod.py

 # 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')