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

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

Comments

Siddharth Agarwal - Oct. 8, 2015, 7:33 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@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.
Pierre-Yves David - Oct. 8, 2015, 10:46 a.m.
On 10/08/2015 12:33 AM, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@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

Patches 1-5 are pushed to the clowncopter. Patch 6 is a bit more beefy 
and will get love tomorrow.

Patch

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: