[PATCH 2 of 5 mergedriver V2] filemerge: return whether the file is deleted for nomerge internal tools

Siddharth Agarwal sid0 at fb.com
Thu Nov 19 12:53:05 CST 2015


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1447883548 28800
#      Wed Nov 18 13:52:28 2015 -0800
# Node ID bea5b9e9469807afa0c56144acd2c7d3db0dcc49
# Parent  d8fbf332f479112273693c0db4aaa7d0b115912d
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r bea5b9e94698
filemerge: return whether the file is deleted for nomerge internal tools

We're going to support the filemerge code resolving change/delete conflicts in
upcoming patches. Some of these resolutions require that the dirstate be
modified. Modifying the dirstate directly from in here would be (a) a pretty
bad layering violation and (b) wrong because all dirstate removals should
happen before adds. So in this and upcoming patches we're instead going to pass
whether the file is deleted up to merge.mergestate, then in there figure out
what dirstate action needs to be taken.

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -232,18 +232,18 @@ def _iprompt(repo, mynode, orig, fcd, fc
             return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf)
     except error.ResponseExpected:
         ui.write("\n")
-        return 1
+        return 1, False
 
 @internaltool('local', nomerge)
 def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf):
     """Uses the local version of files as the merged version."""
-    return 0
+    return 0, False
 
 @internaltool('other', nomerge)
 def _iother(repo, mynode, orig, fcd, fco, fca, toolconf):
     """Uses the other version of files as the merged version."""
     repo.wwrite(fcd.path(), fco.data(), fco.flags())
-    return 0
+    return 0, False
 
 @internaltool('fail', nomerge)
 def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf):
@@ -251,7 +251,7 @@ def _ifail(repo, mynode, orig, fcd, fco,
     Rather than attempting to merge files that were modified on both
     branches, it marks them as unresolved. The resolve command must be
     used to resolve these conflicts."""
-    return 1
+    return 1, False
 
 def _premerge(repo, toolconf, files, labels=None):
     tool, toolpath, binary, symlink = toolconf
@@ -536,7 +536,8 @@ def _filemerge(premerge, repo, mynode, o
     toolconf = tool, toolpath, binary, symlink
 
     if mergetype == nomerge:
-        return True, func(repo, mynode, orig, fcd, fco, fca, toolconf)
+        r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf)
+        return True, r
 
     if premerge:
         if orig != fco.path():


More information about the Mercurial-devel mailing list