Patchwork [4,of,5,mergedriver,V2] filemerge: return whether the file was deleted

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 19, 2015, 6:53 p.m.
Message ID <5ac34a97b978556e38e2.1447959187@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11526/
State Accepted
Headers show

Comments

Siddharth Agarwal - Nov. 19, 2015, 6:53 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1447885372 28800
#      Wed Nov 18 14:22:52 2015 -0800
# Node ID 5ac34a97b978556e38e2e264ecefb7e903e98c16
# Parent  9e1889bae61fc0ffc961ba6ccec9c99d2107fc04
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r 5ac34a97b978
filemerge: return whether the file was deleted

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
@@ -561,7 +561,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, False
 
 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
@@ -497,8 +497,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 boolean indicating whether the file was deleted from disk."""
 
     def temp(prefix, ctx):
         pre = "%s~%s." % (os.path.basename(ctx.path()), prefix)
@@ -510,7 +510,7 @@  def _filemerge(premerge, repo, mynode, o
         return name
 
     if not fco.cmp(fcd): # files identical?
-        return True, None
+        return True, None, False
 
     ui = repo.ui
     fd = fcd.path()
@@ -538,7 +538,7 @@  def _filemerge(premerge, repo, mynode, o
 
     if mergetype == nomerge:
         r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf)
-        return True, r
+        return True, r, deleted
 
     if premerge:
         if orig != fco.path():
@@ -552,7 +552,7 @@  def _filemerge(premerge, repo, mynode, o
                                  toolconf):
         if onfailure:
             ui.warn(onfailure % fd)
-        return True, 1
+        return True, 1, False
 
     a = repo.wjoin(fd)
     b = temp("base", fca)
@@ -573,7 +573,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, False
 
         needcheck, r, deleted = func(repo, mynode, orig, fcd, fco, fca,
                                      toolconf, files, labels=labels)
@@ -585,7 +585,7 @@  def _filemerge(premerge, repo, mynode, o
             if onfailure:
                 ui.warn(onfailure % fd)
 
-        return True, r
+        return True, r, deleted
     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
@@ -432,11 +432,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, deleted = 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, deleted = filemerge.filemerge(self._repo, self._local,
+                                                       lfile, fcd, fco, fca,
+                                                       labels=labels)
         if r is None:
             # no real conflict
             del self._state[dfile]