[PATCH 3 of 5] merge: synthesize L+O records in mergestate for conflictfree merges

timeless timeless at mozdev.org
Thu Mar 17 11:46:50 EDT 2016


# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1458226168 0
#      Thu Mar 17 14:49:28 2016 +0000
# Node ID 90b56e5e614a0696ded4e75349317b55b9c30533
# Parent  18892389001b3c991524cf04bbb004a7a1a15188
merge: synthesize L+O records in mergestate for conflictfree merges

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -189,13 +189,21 @@
         returns list of record [(TYPE, data), ...]"""
         v1records = self._readrecordsv1()
         v2records = self._readrecordsv2()
+        parents = self._repo[None].parents()
+        if len(parents) == 2 and not v1records and not v2records:
+            # if we have two parents, we have a merge,
+            # but if there were no conflicts, there will not be a mergestate.
+            # localctx and otherctx expect L and O records to be present, so
+            # synthesize them.
+            p1, p2 = parents
+            return [('L', hex(p1.node())), ('O', hex(p2.node()))]
         if self._v1v2match(v1records, v2records):
             return v2records
         else:
             # v1 file is newer than v2 file, use it
             # we have to infer the "other" changeset of the merge
             # we cannot do better than that with v1 of the format
-            mctx = self._repo[None].parents()[-1]
+            mctx = parents[-1]
             v1records.append(('O', mctx.hex()))
             # add place holder "other" file node information
             # nobody is using it yet so we do no need to fetch the data


More information about the Mercurial-devel mailing list