[PATCH 5 of 6 mergedriver] filemerge: move precheck to before files are written out

Siddharth Agarwal sid0 at fb.com
Thu Oct 8 02:33:16 CDT 2015


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1444278523 25200
#      Wed Oct 07 21:28:43 2015 -0700
# Node ID 57d94e0c31e4072ffdf0aa4a7fa2934e22dfe068
# Parent  5436157f86676d0d7cc7e6d49ad462a0c63938ce
filemerge: move precheck to before files are written out

This is much simpler, and also avoids unnecessary disk IO.

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -500,6 +500,12 @@ def filemerge(repo, mynode, orig, fcd, f
 
         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 @@ def filemerge(repo, mynode, orig, fcd, f
         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:


More information about the Mercurial-devel mailing list