Commits

Nathan Durnan  committed 14312b9

Replaced hard-coded Timestamp Record filename with a variable.
Should make it possible to set the filename via config files later.

  • Participants
  • Parent commits 3bc6731
  • Branches development
  • Tags Version 0.0.1

Comments (0)

Files changed (1)

File TimestampMod.py

 #==============================================================================
 # Global Objects
 #------------------------------------------------------------------------------
+File_TimestampRecords = '.hgtimestamp'
 TimeStamp_dict = dict()
 List_CommitMatch = []
 #_ end of global objects ______________________________________________________
 	else:
 		pass
 	# End of check for non-existent match object.
-	List_CommitMatch = myMatch.files() + ['.hgtimestamp']
+	List_CommitMatch = myMatch.files() + [File_TimestampRecords]
 	
 	timestamp_mod(repo.ui, repo, **dict({'save': True, 'restore': None}))
 	# Make sure record file is part of commit. 
-	if '.hgtimestamp' in myMatch.files():
+	if File_TimestampRecords in myMatch.files():
 		# Don't need to do anything if record file already in commit.
 		pass
 	else:
 		# Add the record file to the match object.
-		myMatch.files().append('.hgtimestamp')
+		myMatch.files().append(File_TimestampRecords)
 	# end of check for record file.
 	repo.ui.debug('Match Files: ', str(myMatch.files()), '\n')
 	return repo.timestamp_origcommit(text, user, date, myMatch, force, editor, extra)
 #==============================================================================
 def Hook_Pre_Commit(repo, **kwargs):
 	timestamp_mod(repo.ui, repo, **dict({'save': True, 'restore': None}))
-	kwargs['pats'].append('.hgtimestamp')
+	kwargs['pats'].append(File_TimestampRecords)
 
 def Hook_Post_Status(repo, **kwargs):
 	timestamp_mod(repo.ui, repo, **dict({'save': None, 'restore': None}))
 	'''Read data from Timestamp Record File.'''
 	myTimeStampRecordsFile = ''
 	try:
-		myTimeStampRecordsFile = file(repo.root+'/.hgtimestamp', 'r')
+		myTimeStampRecordsFile = file(repo.wjoin(File_TimestampRecords), 'r')
 		repo.ui.debug('______\nRetrieveing timestamps from record file:\n------\n')
 		for myLine in myTimeStampRecordsFile.readlines():
 			# Read the data from the line. (CSV format: [FileName],[ModificationTime])
 		# end of readlines from record file.
 		myTimeStampRecordsFile.close()
 	except:
-		repo.ui.warn('*** Error accessing .hgtimestamp file! ***\n')
+		repo.ui.warn('*** Error accessing ', File_TimestampRecords, ' file! ***\n')
 	# end of accessing record file.
 #_ end of _read_TimestampRecords ______________________________________________
 
 def _save_Timestamps(repo, myChangedList):
 	'''Save File Modification Timestamps to record file.'''
 	repo.ui.note('______\nSaving timestamps...\n------\n')
-	file_TimeStampRecords = file(repo.root+'/.hgtimestamp', 'w')
+	myTimeStampRecordsFile = file(repo.wjoin(File_TimestampRecords), 'w')
 	# Remove the record file from the list to loop through.
 	#	It will be updated separately at the end.
-	if '.hgtimestamp' in TimeStamp_dict:
-		del TimeStamp_dict['.hgtimestamp']
+	if File_TimestampRecords in TimeStamp_dict:
+		del TimeStamp_dict[File_TimestampRecords]
 	# end of check for record file.
 	for s_fileName, f_fileModTime in TimeStamp_dict.items():
 		if (s_fileName in myChangedList) or (f_fileModTime<=0):
 			f_fileModTime = TimeStamp_dict[s_fileName] = _get_fileModTime(repo, s_fileName)
 		# end of update timestamps for changed items or missing timestamps.
-		file_TimeStampRecords.write("%s,%s\n" % (s_fileName, f_fileModTime))
+		myTimeStampRecordsFile.write("%s,%s\n" % (s_fileName, f_fileModTime))
 	# end of loop through dictionary items.
 	# Update the record file timestamp last with the current time.
-	f_fileModTime = TimeStamp_dict['.hgtimestamp'] = time.time()
-	file_TimeStampRecords.write("%s,%s\n" % ('.hgtimestamp', f_fileModTime))
+	f_fileModTime = TimeStamp_dict[File_TimestampRecords] = time.time()
+	myTimeStampRecordsFile.write("%s,%s\n" % (File_TimestampRecords, f_fileModTime))
 	# Make sure to close the file!
-	file_TimeStampRecords.close()
+	myTimeStampRecordsFile.close()
 #_ end of _save_Timestamps ____________________________________________________