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

login
register
mail settings
Submitter Siddharth Agarwal
Date Oct. 13, 2015, 10:10 p.m.
Message ID <92f202bf94b72ce19a97.1444774215@dev6666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11027/
State Accepted
Headers show

Comments

Siddharth Agarwal - Oct. 13, 2015, 10:10 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1443490446 25200
#      Mon Sep 28 18:34:06 2015 -0700
# Node ID 92f202bf94b72ce19a979b71aa973aa54dea9cc4
# Parent  d5137bc7dc43dfbe0e69a115ea1fd548fb6f7e01
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)
 
@@ -125,7 +127,7 @@  class mergestate(object):
                         _("merge driver changed since merge started"),
                         hint=_("revert merge driver change or abort merge"))
                 self._mdstate = mdstate
-            elif rtype == 'F':
+            elif rtype in 'FD':
                 bits = record.split('\0')
                 self._state[bits[0]] = bits[1:]
             elif not rtype.islower():
@@ -254,7 +256,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