Patchwork [4,of,9,mergedriver] filemerge: call precheck if available

login
register
mail settings
Submitter Siddharth Agarwal
Date Oct. 7, 2015, 7:33 a.m.
Message ID <8565edbcce1d540c4781.1444203219@dev6666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/10848/
State Accepted
Headers show

Comments

Siddharth Agarwal - Oct. 7, 2015, 7:33 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1444197321 25200
#      Tue Oct 06 22:55:21 2015 -0700
# Node ID 8565edbcce1d540c478149eee0a92dbca556c65b
# Parent  d742ca75b75ab951f6c05b7e0e24cc6e58eecf96
filemerge: call precheck if available

In upcoming patches we'll define a precheck function for some merge tools.

Patch

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -483,10 +483,12 @@  class mergectx(object):
             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
 
@@ -506,14 +508,22 @@  class mergectx(object):
 
         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: