changeset 27035:de7bf242644e

merge.mergestate: compute dirstate action In upcoming patches we're going to queue these actions up to be applied to the dirstate at the end.
author Siddharth Agarwal <sid0@fb.com>
date Thu, 19 Nov 2015 10:50:02 -0800
parents 86ede9eda252
children 63d6bc874dea
files mercurial/merge.py
diffstat 1 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Wed Nov 18 14:22:52 2015 -0800
+++ b/mercurial/merge.py	Thu Nov 19 10:50:02 2015 -0800
@@ -410,7 +410,7 @@
     def _resolve(self, preresolve, dfile, wctx, labels=None):
         """rerun merge process for file path `dfile`"""
         if self[dfile] in 'rd':
-            return True, 0
+            return True, 0, None
         stateentry = self._state[dfile]
         state, hash, lfile, afile, anode, ofile, onode, flags = stateentry
         octx = self._repo[self._other]
@@ -445,19 +445,36 @@
             self._dirty = True
         elif not r:
             self.mark(dfile, 'r')
-        return complete, r
+
+        action = None
+        if complete:
+            if deleted:
+                if not fcd.isabsent():
+                    # cd: remote picked (or otherwise deleted)
+                    action = 'r'
+                # else: dc: local picked (no action necessary)
+            else:
+                if fcd.isabsent(): # dc: remote picked
+                    action = 'g'
+                elif fco.isabsent(): # cd: local picked
+                    action = 'a'
+                # else: regular merges (no action necessary)
+
+        return complete, r, action
 
     def preresolve(self, dfile, wctx, labels=None):
         """run premerge process for dfile
 
         Returns whether the merge is complete, and the exit code."""
-        return self._resolve(True, dfile, wctx, labels=labels)
+        complete, r, action = self._resolve(True, dfile, wctx, labels=labels)
+        return complete, r
 
     def resolve(self, dfile, wctx, labels=None):
         """run merge process (assuming premerge was run) for dfile
 
         Returns the exit code of the merge."""
-        return self._resolve(False, dfile, wctx, labels=labels)[1]
+        complete, r, action = self._resolve(False, dfile, wctx, labels=labels)
+        return r
 
 def _checkunknownfile(repo, wctx, mctx, f, f2=None):
     if f2 is None: