[PATCH 6 of 7] context: introduce [ui]topancestor for controlling which ancestor to pick

Mads Kiilerich mads at kiilerich.com
Mon Feb 24 16:19:15 CST 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1393278134 -3600
#      Mon Feb 24 22:42:14 2014 +0100
# Node ID c5b597a62f2231919df87fe2915a4edf1023166b
# Parent  d6e2126534dce3cc4dea26c5e869f72a44353a47
context: introduce [ui]topancestor for controlling which ancestor to pick

Multiple revisions can be specified in ui.topancestor, separated by whitespace.
First match wins.

This makes it possible to overrule the default of picking the common ancestor
with the lowest hash value.

This can for instance help with some merges where the 'wrong' ancestor is used.
There will thus be some overlap between this and the problems that can be
solved with a future 'consensus merge'.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -410,6 +410,12 @@
                 _("warning: multiple ancestors of %s and %s: %s\n") %
                 (short(self._node), short(n2),
                  ' '.join(short(n) for n in sorted(ancs))))
+            for r in self._repo.ui.config('ui', 'topancestors', '').split():
+                ctx = changectx(self._repo, r)
+                if ctx.node() in ancs:
+                    self._repo.ui.status(_('picked topancestor %s\n') %
+                                         short(ctx.node()))
+                    return ctx
         return changectx(self._repo, min(ancs))
 
     def descendant(self, other):


More information about the Mercurial-devel mailing list