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

mail settings
Submitter Mads Kiilerich
Date Feb. 24, 2014, 10:19 p.m.
Message ID <c5b597a62f2231919df8.1393280355@mk-desktop>
Download mbox | patch
Permalink /patch/3749/
State Deferred
Headers show


Mads Kiilerich - Feb. 24, 2014, 10:19 p.m.
# HG changeset patch
# User Mads Kiilerich <>
# 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/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -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):