Patchwork [7,of,7,mergedriver] mergestate: allow storing and retrieving change/delete conflicts

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 16, 2015, 11:46 p.m.
Message ID <c5c0131799323cf9d85c.1447717571@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11418/
State Superseded
Commit 8be0af32e5134af59057c0432f5e756608fe5d4e
Headers show

Comments

Siddharth Agarwal - Nov. 16, 2015, 11:46 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1447485379 28800
#      Fri Nov 13 23:16:19 2015 -0800
# Node ID c5c0131799323cf9d85c520264e05cbfa228b1bf
# Parent  c56137c086886035f7798a28d901bd794def8680
mergestate: allow storing and retrieving change/delete conflicts

We introduce a new record type, 'C', to indicate change/delete conflicts. This
is a separate record type because older versions of Mercurial will not be able
to handle these conflicts.

We aren't actually storing any change/delete conflicts yet -- that will come in
future patches.
Martin von Zweigbergk - Nov. 17, 2015, 12:01 a.m.
On Mon, Nov 16, 2015 at 3:49 PM Siddharth Agarwal <sid0@fb.com> wrote:

> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1447485379 28800
> #      Fri Nov 13 23:16:19 2015 -0800
> # Node ID c5c0131799323cf9d85c520264e05cbfa228b1bf
> # Parent  c56137c086886035f7798a28d901bd794def8680
> mergestate: allow storing and retrieving change/delete conflicts
>
> We introduce a new record type, 'C', to indicate change/delete conflicts.
> This
> is a separate record type because older versions of Mercurial will not be
> able
> to handle these conflicts.
>

How will an old client behave if it runs into these records? "hg checkout
-C" will hopefully still work, if that's even a requirement, I don't know.


>
> We aren't actually storing any change/delete conflicts yet -- that will
> come in
> future patches.
>
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -16,6 +16,7 @@ from .i18n import _
>  from .node import (
>      bin,
>      hex,
> +    nullhex,
>      nullid,
>      nullrev,
>  )
> @@ -61,6 +62,7 @@ class mergestate(object):
>      L: the node of the "local" part of the merge (hexified version)
>      O: the node of the "other" part of the merge (hexified version)
>      F: a file to be merged entry
> +    C: a change/delete or delete/change conflict
>      D: a file that the external merge driver will merge internally
>         (experimental)
>      m: the external merge driver defined for this merge plus its run state
> @@ -125,7 +127,7 @@ class mergestate(object):
>
>                  self._readmergedriver = bits[0]
>                  self._mdstate = mdstate
> -            elif rtype in 'FD':
> +            elif rtype in 'FDC':
>                  bits = record.split('\0')
>                  self._state[bits[0]] = bits[1:]
>              elif not rtype.islower():
> @@ -273,6 +275,10 @@ class mergestate(object):
>                  records.append(('m', '\0'.join([
>                      self.mergedriver, self._mdstate])))
>              for d, v in self._state.iteritems():
> +                # v[1] == local ('cd'), v[6] == other ('dc') -- not
> supported by
> +                # older versions of Mercurial
> +                if v[1] == nullhex or v[6] == nullhex:
> +                    records.append(('C', '\0'.join([d] + v)))
>                  if v[0] == 'd':
>                      records.append(('D', '\0'.join([d] + v)))
>                  else:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
>
Siddharth Agarwal - Nov. 17, 2015, 12:14 a.m.
On 11/16/15 16:01, Martin von Zweigbergk wrote:
>
> How will an old client behave if it runs into these records? "hg 
> checkout -C" will hopefully still work, if that's even a requirement, 
> I don't know.

Yes, hg update -C to abort the merge and update cleanly elsewhere will 
still (hopefully!) work. Let me double check that, though!
Siddharth Agarwal - Nov. 17, 2015, 12:18 a.m.
On 11/16/15 16:14, Siddharth Agarwal wrote:
> Yes, hg update -C to abort the merge and update cleanly elsewhere will 
> still (hopefully!) work. Let me double check that, though! 

I just double checked. It doesn't actually work. Well crap. We may need 
a v3 mergestate that is identical to the v2 mergestate but actually 
fixes this. :/

- Siddharth
Martin von Zweigbergk - Nov. 17, 2015, 12:21 a.m.
On Mon, Nov 16, 2015 at 4:18 PM Siddharth Agarwal <sid@less-broken.com>
wrote:

> On 11/16/15 16:14, Siddharth Agarwal wrote:
> > Yes, hg update -C to abort the merge and update cleanly elsewhere will
> > still (hopefully!) work. Let me double check that, though!
>
> I just double checked. It doesn't actually work. Well crap. We may need
> a v3 mergestate that is identical to the v2 mergestate but actually
> fixes this. :/
>
> - Siddharth
>

:-(

I did this: http://42.netv6.net/martinvonz-wip/mercurial/rev/eaf9d55e231e.
I remember talking a bit to Matt and I think this was his recommendation.
He did talk about BC, and this problem might be the reason, I don't quite
remember.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -16,6 +16,7 @@  from .i18n import _
 from .node import (
     bin,
     hex,
+    nullhex,
     nullid,
     nullrev,
 )
@@ -61,6 +62,7 @@  class mergestate(object):
     L: the node of the "local" part of the merge (hexified version)
     O: the node of the "other" part of the merge (hexified version)
     F: a file to be merged entry
+    C: a change/delete or delete/change conflict
     D: a file that the external merge driver will merge internally
        (experimental)
     m: the external merge driver defined for this merge plus its run state
@@ -125,7 +127,7 @@  class mergestate(object):
 
                 self._readmergedriver = bits[0]
                 self._mdstate = mdstate
-            elif rtype in 'FD':
+            elif rtype in 'FDC':
                 bits = record.split('\0')
                 self._state[bits[0]] = bits[1:]
             elif not rtype.islower():
@@ -273,6 +275,10 @@  class mergestate(object):
                 records.append(('m', '\0'.join([
                     self.mergedriver, self._mdstate])))
             for d, v in self._state.iteritems():
+                # v[1] == local ('cd'), v[6] == other ('dc') -- not supported by
+                # older versions of Mercurial
+                if v[1] == nullhex or v[6] == nullhex:
+                    records.append(('C', '\0'.join([d] + v)))
                 if v[0] == 'd':
                     records.append(('D', '\0'.join([d] + v)))
                 else: