Patchwork [5,of,5,mergedriver,V2] merge.mergestate: compute dirstate action

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

Comments

Siddharth Agarwal - Nov. 19, 2015, 6:53 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1447959002 28800
#      Thu Nov 19 10:50:02 2015 -0800
# Node ID 0ce719f9080e9dccb02929b675a14f1b36bf74f4
# Parent  5ac34a97b978556e38e2e264ecefb7e903e98c16
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r 0ce719f9080e
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.
Martin von Zweigbergk - Nov. 19, 2015, 9:22 p.m.
These are pushed to the clowncopter, thanks!

On Thu, Nov 19, 2015 at 10:57 AM Siddharth Agarwal <sid0@fb.com> wrote:

> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1447959002 28800
> #      Thu Nov 19 10:50:02 2015 -0800
> # Node ID 0ce719f9080e9dccb02929b675a14f1b36bf74f4
> # Parent  5ac34a97b978556e38e2e264ecefb7e903e98c16
> # Available At http://42.netv6.net/sid0-wip/hg/
> #              hg pull http://42.netv6.net/sid0-wip/hg/ -r 0ce719f9080e
> 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.
>
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -410,7 +410,7 @@ class mergestate(object):
>      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,35 @@ class mergestate(object):
>              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)
>

test-check-code-hg.t did not like the long line, so I moved the comment to
the next line.


> +                    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:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -410,7 +410,7 @@  class mergestate(object):
     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,35 @@  class mergestate(object):
             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: