diff mercurial/filemerge.py @ 12788:de793925862e

merge: implement --tool arguments using new ui.forcemerge configurable ui.forcemerge is set before calling into merge or resolve commands, then unset to prevent ui pollution for further operations. ui.forcemerge takes precedence over HGMERGE, but mimics HGMERGE behavior if the given --tool is not found by the merge-tools machinery. This makes it possible to do: hg resolve --tool="python mymerge.py" FILE With this approach, HGMERGE and ui.merge are not harmed by --tool
author Steve Borho <steve@borho.org>
date Tue, 19 Oct 2010 22:33:52 -0500
parents dee1901a0ed8
children 984175605311
line wrap: on
line diff
--- a/mercurial/filemerge.py	Wed Oct 20 20:19:34 2010 +0200
+++ b/mercurial/filemerge.py	Tue Oct 19 22:33:52 2010 -0500
@@ -54,7 +54,17 @@
             return True
         return False
 
-    # HGMERGE takes precedence
+    # forcemerge comes from command line arguments, highest priority
+    force = ui.config('ui', 'forcemerge')
+    if force:
+        toolpath = _findtool(ui, force)
+        if toolpath:
+            return (force, '"' + toolpath + '"')
+        else:
+            # mimic HGMERGE if given tool not found
+            return (force, force)
+
+    # HGMERGE takes next precedence
     hgmerge = os.environ.get("HGMERGE")
     if hgmerge:
         return (hgmerge, hgmerge)