[PATCH 2 of 7 V2 mergedriver] filemerge: also return whether the merge is complete

Siddharth Agarwal sid0 at fb.com
Mon Oct 12 02:45:37 CDT 2015


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1444593381 25200
#      Sun Oct 11 12:56:21 2015 -0700
# Node ID 23d773a1a116fa545dacda86f0a0cea76cf347cf
# Parent  395dc7b3880c9e2b3c485a418237cb8ca9191687
filemerge: also return whether the merge is complete

In future patches, we'll pause merges after the premerge step. After the
premerge step we'll return complete = False.

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -553,7 +553,7 @@ def overridefilemerge(origfn, repo, myno
                (lfutil.splitstandin(orig), ahash, dhash, ohash),
              0) == 1)):
         repo.wwrite(fcd.path(), fco.data(), fco.flags())
-    return 0
+    return True, 0
 
 def copiespathcopies(orig, ctx1, ctx2, match=None):
     copies = orig(ctx1, ctx2, match=match)
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -443,6 +443,8 @@ def _filemerge(repo, mynode, orig, fcd, 
     fco = other file context
     fca = ancestor file context
     fcd = local file context for current/destination file
+
+    Returns whether the merge is complete, and the return value of the merge.
     """
 
     if True:
@@ -456,7 +458,7 @@ def _filemerge(repo, mynode, orig, fcd, 
             return name
 
         if not fco.cmp(fcd): # files identical?
-            return None
+            return True, None
 
         ui = repo.ui
         fd = fcd.path()
@@ -483,7 +485,7 @@ def _filemerge(repo, mynode, orig, fcd, 
         toolconf = tool, toolpath, binary, symlink
 
         if mergetype == nomerge:
-            return func(repo, mynode, orig, fcd, fco, fca, toolconf)
+            return True, func(repo, mynode, orig, fcd, fco, fca, toolconf)
 
         if orig != fco.path():
             ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
@@ -496,7 +498,7 @@ def _filemerge(repo, mynode, orig, fcd, 
                                      toolconf):
             if onfailure:
                 ui.warn(onfailure % fd)
-            return 1
+            return True, 1
 
         a = repo.wjoin(fd)
         b = temp("base", fca)
@@ -529,7 +531,7 @@ def _filemerge(repo, mynode, orig, fcd, 
             if onfailure:
                 ui.warn(onfailure % fd)
 
-        return r
+        return True, r
     finally:
         if not r:
             util.unlink(back)
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -309,8 +309,8 @@ class mergestate(object):
         f = self._repo.vfs('merge/' + hash)
         self._repo.wwrite(dfile, f.read(), flags)
         f.close()
-        r = filemerge.filemerge(self._repo, self._local, lfile, fcd, fco, fca,
-                                labels=labels)
+        complete, r = filemerge.filemerge(self._repo, self._local, lfile, fcd,
+                                          fco, fca, labels=labels)
         if r is None:
             # no real conflict
             del self._state[dfile]


More information about the Mercurial-devel mailing list