mergestate: allow storing and retrieving change/delete conflicts
authorSiddharth Agarwal <sid0@fb.com>
Wed, 18 Nov 2015 15:46:45 -0800
changeset 27031 8be0af32e513
parent 27030 cf9ed6d32ccb
child 27032 28ee7af4b685
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.
mercurial/merge.py
--- a/mercurial/merge.py	Thu Nov 19 12:50:10 2015 +0530
+++ b/mercurial/merge.py	Wed Nov 18 15:46:45 2015 -0800
@@ -16,6 +16,7 @@
 from .node import (
     bin,
     hex,
+    nullhex,
     nullid,
     nullrev,
 )
@@ -58,6 +59,7 @@
     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 @@
 
                 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 @@
         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