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

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

Comments

Siddharth Agarwal - Nov. 19, 2015, 6:53 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1447890405 28800
#      Wed Nov 18 15:46:45 2015 -0800
# Node ID d8fbf332f479112273693c0db4aaa7d0b115912d
# Parent  e70e9063ab8d54791e27687a1744bf7330b69732
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r d8fbf332f479
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.

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,
 )
@@ -58,6 +59,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
@@ -143,7 +145,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():
@@ -315,6 +317,10 @@  class mergestate(object):
         for d, v in self._state.iteritems():
             if v[0] == 'd':
                 records.append(('D', '\0'.join([d] + v)))
+            # v[1] == local ('cd'), v[6] == other ('dc') -- not supported by
+            # older versions of Mercurial
+            elif v[1] == nullhex or v[6] == nullhex:
+                records.append(('C', '\0'.join([d] + v)))
             else:
                 records.append(('F', '\0'.join([d] + v)))
         return records