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

Simon Farnsworth simonfar at fb.com
Fri Mar 18 12:01:36 EDT 2016


On 17/03/2016, 08:46, "Mercurial-devel on behalf of timeless" <mercurial-devel-bounces at mercurial-scm.org on behalf of timeless at mozdev.org> wrote:



># 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

Why do we need this? What use is localctx and otherctx if you're not going to attempt a fresh merge (I have some thoughts, but...).

Would we be better off with (local|other)ctx succeeding rather than throwing an exception if there's no record for the merge point?
>
>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
>_______________________________________________
>Mercurial-devel mailing list
>Mercurial-devel at mercurial-scm.org
>https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=CwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=mEgSWILcY4c4W3zjApBQLA&m=bTYiH16NgzwNQ_W3jCgf3iVQRprWPTzcCMkv-cDa8yI&s=RwKOhGBbGGnZkvb2qqOLfMqAm4_TQ37vU2D3ts0KqD8&e= 


More information about the Mercurial-devel mailing list