Patchwork [4,of,5,mergedriver] mergestate: add methods to queue files to remove, add or get

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 23, 2015, 6 a.m.
Message ID <39b2bc59e3b1d7ef13c9.1448258450@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11592/
State Accepted
Headers show

Comments

Siddharth Agarwal - Nov. 23, 2015, 6 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1448258392 28800
#      Sun Nov 22 21:59:52 2015 -0800
# Node ID 39b2bc59e3b1d7ef13c996b30fafa293c6116854
# Parent  bc37d2bf7a29597601a08bbb37139a1b80550c39
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r 39b2bc59e3b1
mergestate: add methods to queue files to remove, add or get

These are meant for use by custom merge drivers that might want to modify the
dirstate. Dirstate internal consistency rules require that all removes happen
before any adds -- this means that custom merge drivers shouldn't be modifying
the dirstate directly.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -522,6 +522,24 @@  class mergestate(object):
         branchmerge = self._repo.dirstate.p2() != nullid
         recordupdates(self._repo, self.actions(), branchmerge)
 
+    def queueremove(self, f):
+        """queues a file to be removed from the dirstate
+
+        Meant for use by custom merge drivers."""
+        self._results[f] = 0, 'r'
+
+    def queueadd(self, f):
+        """queues a file to be added to the dirstate
+
+        Meant for use by custom merge drivers."""
+        self._results[f] = 0, 'a'
+
+    def queueget(self, f):
+        """queues a file to be marked modified in the dirstate
+
+        Meant for use by custom merge drivers."""
+        self._results[f] = 0, 'g'
+
 def _checkunknownfile(repo, wctx, mctx, f, f2=None):
     if f2 is None:
         f2 = f