changeset 26567:f18646cf0e93

filemerge: call premerge directly from main merge function The merge code currently does (in pseudocode): for f in tomerge: premerge f merge f We'd like to change this to look more like: for f in tomerge: premerge f for f in tomerge: merge f This makes sure as many files are resolved as possible before prompting for the others. This restructuring is also necessary for custom merge drivers. This function separates out the premerge step from the merge step. In future patches we'll actually turn these into separate steps in the merge driver. The 'if r:' occurrences will be cleaned up in subsequent patches.
author Siddharth Agarwal <sid0@fb.com>
date Wed, 07 Oct 2015 21:22:16 -0700
parents 58880acd2369
children c0501c26b05c
files mercurial/filemerge.py
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/filemerge.py	Mon Oct 05 16:19:54 2015 -0700
+++ b/mercurial/filemerge.py	Wed Oct 07 21:22:16 2015 -0700
@@ -247,7 +247,7 @@
     files. It will fail if there are any conflicts and leave markers in
     the partially merged file. Markers will have two sections, one for each side
     of merge, unless mode equals 'union' which suppresses the markers."""
-    r = _premerge(repo, toolconf, files, labels=labels)
+    r = 1
     if r:
         a, b, c, back = files
 
@@ -349,7 +349,7 @@
     ``a.txt``, these files will accordingly be named ``a.txt.local``,
     ``a.txt.other`` and ``a.txt.base`` and they will be placed in the
     same directory as ``a.txt``."""
-    r = _premerge(repo, toolconf, files, labels=labels)
+    r = 1
     if r:
         a, b, c, back = files
 
@@ -361,7 +361,7 @@
     return False, r
 
 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
-    r = _premerge(repo, toolconf, files, labels=labels)
+    r = 1
     if r:
         tool, toolpath, binary, symlink = toolconf
         a, b, c, back = files
@@ -519,8 +519,15 @@
         if markerstyle != 'basic':
             labels = _formatlabels(repo, fcd, fco, fca, labels)
 
-        needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf, files,
-                            labels=labels)
+        r = 1
+        if mergetype == fullmerge:
+            r = _premerge(repo, toolconf, files, labels=labels)
+
+        if not r:  # premerge successfully merged the file
+            needcheck = False
+        else:
+            needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf,
+                                files, labels=labels)
 
         if not needcheck:
             if r: