Commits

Nathan Durnan  committed 8a8d431

BitBucket Issue #27 - Timestamps not correct after Merge

  • Participants
  • Parent commits 2642ad8
  • Branches BBI#27

Comments (0)

Files changed (2)

File .hgtimestamp

 .hgtags,1323983941.97
 README.rst,1312921197.45
 TimeStampMod.png,1305052883.0
-TimestampMod.py,1327960495.36
+TimestampMod.py,1328126718.52
 TimeStampMod.xmind,1306451621.66

File TimestampMod.py

 	# Hook_Pre_Commit is depreciated in favor of Wrap_Commit method
 	#	(Wrap_Commit works with both native Mercurial and TortoiseHg.)
 	'''ui.setconfig("hooks", "pre-commit.TimestampMod", Hook_Pre_Commit)'''
+	ui.setconfig("hooks", "post-merge.TimestampMod", Hook_Post_Merge)
 #_ end of uisetup _____________________________________________________________
 
 
 	#Check for a merge-commit. 
 	#  Don't run timestamp code on merge.
 	if (len(repo.parents()) > 1):
-		repo.ui.status('Wrap_Commit aborted - Merge in progress\n')
+		repo.ui.status('TimestampMod|Wrap_Commit aborted - Merge in progress\n')
 	else:
 		# Make sure the match object is created.
 		if not match:
 	kwargs['pats'].append(File_TimestampRecords)
 ''' # Hook_Pre_Commit is depreciated
 def Hook_Post_Status(repo, **kwargs):
-	repo.ui.note("Post-Status Hook accessed!\n")
+	repo.ui.note("TimestampMod|Post-Status Hook accessed!\n")
 	timestamp_mod(repo.ui, repo, **dict({'save': None, 'restore': None}))
 
 def Hook_Update(repo, **kwargs):
-	repo.ui.note("Update Hook accessed!\n")
-	timestamp_mod(repo.ui, repo, **dict({'save': None, 'restore': True}))
+	repo.ui.note("TimestampMod|Hook_Update accessed!\n")
+	if (len(repo.parents()) > 1):
+		repo.ui.status('TimestampMod|Hook_Update aborted - Merge in progress\n')
+	else:
+		timestamp_mod(repo.ui, repo, **dict({'save': None, 'restore': True}))
+	#end of check for merging.
+
+def Hook_Post_Merge(repo, **kwargs):
+	repo.ui.note("TimestampMod|Post-Merge Hook accessed!\n")
+	#repo.ui.status("Post-Merge:kwargs = \n", str(kwargs), '\n')
+	myPreview = False #starting value
+	if ('opts' in kwargs):
+		if ('preview' in kwargs['opts']):
+			myPreview = kwargs['opts']['preview']
+		#end of check for 'preview' option.
+	#end of check for 'opts' keyword.
+	if not myPreview:
+		#only update timestamps if not just a preview.
+		timestamp_mod(repo.ui, repo, **dict({'save': None, 'restore': True}))
+	#check for preview option.
 #_ end of Hook Functions ______________________________________________________