changeset 26529:7833b13b001f

filemerge: move precheck to before files are written out This is much simpler, and also avoids unnecessary disk IO.
author Siddharth Agarwal <sid0@fb.com>
date Wed, 07 Oct 2015 21:28:43 -0700
parents 8bfef5737321
children 52642e12e7b3
files mercurial/filemerge.py
diffstat 1 files changed, 13 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/filemerge.py	Wed Oct 07 22:58:52 2015 -0700
+++ b/mercurial/filemerge.py	Wed Oct 07 21:28:43 2015 -0700
@@ -500,6 +500,12 @@
 
         ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
 
+        if precheck and not precheck(repo, mynode, orig, fcd, fco, fca,
+                                     toolconf):
+            if onfailure:
+                ui.warn(onfailure % fd)
+            return 1
+
         a = repo.wjoin(fd)
         b = temp("base", fca)
         c = temp("other", fco)
@@ -507,21 +513,14 @@
         util.copyfile(a, back)
         files = (a, b, c, back)
 
-        r = 0
-        if precheck and not precheck(repo, mynode, orig, fcd, fco, fca,
-                                     toolconf):
-            r = 1
-            needcheck = False
+        markerstyle = ui.config('ui', 'mergemarkers', 'basic')
+        if not labels:
+            labels = _defaultconflictlabels
+        if markerstyle != 'basic':
+            labels = _formatlabels(repo, fcd, fco, fca, 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,
-                                files, labels=labels)
+        needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf, files,
+                            labels=labels)
 
         if not needcheck:
             if r: