changeset 26514:d5d8cd0e0d58

filemerge: call precheck if available In upcoming patches we'll define a precheck function for some merge tools.
author Siddharth Agarwal <sid0@fb.com>
date Tue, 06 Oct 2015 22:55:21 -0700
parents 01224c28e0ed
children 0ffa7fe1076b
files mercurial/filemerge.py
diffstat 1 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/filemerge.py	Tue Oct 06 22:54:14 2015 -0700
+++ b/mercurial/filemerge.py	Tue Oct 06 22:55:21 2015 -0700
@@ -467,10 +467,12 @@
             func = internals[tool]
             trymerge = func.trymerge
             onfailure = func.onfailure
+            precheck = func.precheck
         else:
             func = _xmerge
             trymerge = True
             onfailure = _("merging %s failed!\n")
+            precheck = None
 
         toolconf = tool, toolpath, binary, symlink
 
@@ -490,14 +492,22 @@
 
         ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
 
-        markerstyle = ui.config('ui', 'mergemarkers', 'basic')
-        if not labels:
-            labels = _defaultconflictlabels
-        if markerstyle != 'basic':
-            labels = _formatlabels(repo, fcd, fco, fca, labels)
+        r = 0
+        if precheck and not precheck(repo, mynode, orig, fcd, fco, fca,
+                                     toolconf):
+            r = 1
+            needcheck = False
 
-        needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf,
-                            (a, b, c, back), labels=labels)
+        if not r:  # precheck passed
+            markerstyle = ui.config('ui', 'mergemarkers', 'basic')
+            if not labels:
+                labels = _defaultconflictlabels
+            if markerstyle != 'basic':
+                labels = _formatlabels(repo, fcd, fco, fca, labels)
+
+            needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf,
+                                (a, b, c, back), labels=labels)
+
         if not needcheck:
             if r:
                 if onfailure: