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

timeless timeless at gmail.com
Thu Mar 17 11:59:33 EDT 2016


It's possible to write a test for this using python, but it doesn't
seem worth it.
Without this change, ~2 of the standard tests would fail for 5 of 5 of
this series:

+    File "mercurial/commands.py", line 6548, in summary
+      if p == ms.localctx:
+    File "mercurial/util.py", line 724, in __get__
+      result = self.func(obj)
+    File "mercurial/merge.py", line 308, in localctx
+      raise RuntimeError("localctx accessed but self._local isn't set")
+  RuntimeError: localctx accessed but self._local isn't set
+  [1]

Failed test-revert.t: output changed
Failed test-backout.t: output changed


On Thu, Mar 17, 2016 at 11:46 AM, timeless <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
>
> 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://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list