Patchwork [3,of,5,changedelete] filemerge: return dirstate action

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 5, 2015, 8:12 a.m.
Message ID <14056ae3782ddc3fee4b.1446711120@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11294/
State Superseded
Headers show

Comments

Siddharth Agarwal - Nov. 5, 2015, 8:12 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1446708798 28800
#      Wed Nov 04 23:33:18 2015 -0800
# Node ID 14056ae3782ddc3fee4b4bb0b9557aa463e08f3c
# Parent  db7ccd556b024d36f50765de8c2d8a08139e867a
filemerge: return dirstate action

This is required for change/delete conflict resolution -- see previous patches
for more details.

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -555,7 +555,7 @@  def overridefilemerge(origfn, premerge, 
                (lfutil.splitstandin(orig), ahash, dhash, ohash),
              0) == 1)):
         repo.wwrite(fcd.path(), fco.data(), fco.flags())
-    return True, 0
+    return True, 0, None
 
 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
@@ -452,8 +452,8 @@  def _filemerge(premerge, repo, mynode, o
     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.
-    """
+    Returns whether the merge is complete, the return value of the merge, and
+    a string indicating how the dirstate needs to be adjusted."""
 
     def temp(prefix, ctx):
         pre = "%s~%s." % (os.path.basename(ctx.path()), prefix)
@@ -465,7 +465,7 @@  def _filemerge(premerge, repo, mynode, o
         return name
 
     if not fco.cmp(fcd): # files identical?
-        return True, None
+        return True, None, None
 
     ui = repo.ui
     fd = fcd.path()
@@ -493,7 +493,7 @@  def _filemerge(premerge, repo, mynode, o
 
     if mergetype == nomerge:
         r, action = func(repo, mynode, orig, fcd, fco, fca, toolconf)
-        return True, r
+        return True, r, action
 
     if premerge:
         if orig != fco.path():
@@ -507,7 +507,7 @@  def _filemerge(premerge, repo, mynode, o
                                  toolconf):
         if onfailure:
             ui.warn(onfailure % fd)
-        return True, 1
+        return True, 1, None
 
     a = repo.wjoin(fd)
     b = temp("base", fca)
@@ -528,7 +528,7 @@  def _filemerge(premerge, repo, mynode, o
         if premerge and mergetype == fullmerge:
             r = _premerge(repo, toolconf, files, labels=labels)
             # complete if premerge successful (r is 0)
-            return not r, r
+            return not r, r, None
 
         needcheck, r, action = func(repo, mynode, orig, fcd, fco, fca, toolconf,
                                     files, labels=labels)
@@ -540,7 +540,7 @@  def _filemerge(premerge, repo, mynode, o
             if onfailure:
                 ui.warn(onfailure % fd)
 
-        return True, r
+        return True, r, action
     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
@@ -381,11 +381,13 @@  class mergestate(object):
             f = self._repo.vfs('merge/' + hash)
             self._repo.wwrite(dfile, f.read(), flags)
             f.close()
-            complete, r = filemerge.premerge(self._repo, self._local, lfile,
-                                             fcd, fco, fca, labels=labels)
+            complete, r, action = filemerge.premerge(self._repo, self._local,
+                                                     lfile, fcd, fco, fca,
+                                                     labels=labels)
         else:
-            complete, r = filemerge.filemerge(self._repo, self._local, lfile,
-                                              fcd, fco, fca, labels=labels)
+            complete, r, action = filemerge.filemerge(self._repo, self._local,
+                                                      lfile, fcd, fco, fca,
+                                                      labels=labels)
         if r is None:
             # no real conflict
             del self._state[dfile]