Patchwork [2,of,5,mergedriver] merge.mergestate: add support for persisting driver-resolved files

login
register
mail settings
Submitter Siddharth Agarwal
Date Oct. 13, 2015, 4:50 a.m.
Message ID <898f85e6b83e73b68fea.1444711803@dev6666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11000/
State Superseded
Commit 6ff5534c8afcf28a9e8f89e89b90c80cf1486236
Headers show

Comments

Siddharth Agarwal - Oct. 13, 2015, 4:50 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1443490446 25200
#      Mon Sep 28 18:34:06 2015 -0700
# Node ID 898f85e6b83e73b68fead89654a878d6bdffa8fb
# Parent  cc121f7aecfb330d82b6c1037a60110ea2a8738d
merge.mergestate: add support for persisting driver-resolved files

A driver-resolved file is a file that's handled specially by the driver. A
common use case for this state would be autogenerated files, the generation of
which should happen only after all source conflicts are resolved.

This is done with an uppercase letter because older versions of Mercurial will
not know how to treat such files at all.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -61,6 +61,8 @@  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
+    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
        (experimental)
 
@@ -116,7 +118,7 @@  class mergestate(object):
 
                 self._mergedriver = bits[0]
                 self._mdstate = mdstate
-            elif rtype == 'F':
+            elif rtype in 'FD':
                 bits = record.split('\0')
                 self._state[bits[0]] = bits[1:]
             elif not rtype.islower():
@@ -241,7 +243,10 @@  class mergestate(object):
                 records.append(('m', '\0'.join([
                     self._mergedriver, self._mdstate])))
             for d, v in self._state.iteritems():
-                records.append(('F', '\0'.join([d] + v)))
+                if v[0] == 'd':
+                    records.append(('D', '\0'.join([d] + v)))
+                else:
+                    records.append(('F', '\0'.join([d] + v)))
             self._writerecords(records)
             self._dirty = False