[PATCH 2 of 3 RFC] context: add a method to return a list of common ancestor changesets

Sean Farley sean at farley.io
Sun May 27 07:48:17 EDT 2018


# HG changeset patch
# User Sean Farley <sean at farley.io>
# Date 1527357601 -7200
#      Sat May 26 20:00:01 2018 +0200
# Node ID 000e9442997b1c61ae02a27e657ffb34d170502b
# Parent  6a31ef919a2440e79a1477d428b46408bf3667ab
# EXP-Topic gca-revset
context: add a method to return a list of common ancestor changesets

This is a convenience method to return a list of common ancestor
changesets between two contexts.

diff --git a/mercurial/context.py b/mercurial/context.py
index 30d57e0..a4d2da1 100644
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -550,10 +550,20 @@ class changectx(basectx):
         n2 = c2._node
         if n2 is None:
             n2 = c2._parents[0]._node
         return n2, self._repo.changelog.commonancestorsheads(self._node, n2)
 
+    def commonancestors(self, c2):
+        """return all ancestor contexts of self and c202c8af058d
+
+        Commonly called the "bid merge" this method returns the common
+        ancestors.
+
+        """
+        n2, cahs = self._commonancestors(c2)
+        return [changectx(self._repo, anc) for anc in cahs]
+
     def ancestor(self, c2, warn=False):
         """return the "best" ancestor context of self and c2
 
         If there are multiple candidates, it will show a message and check
         merge.preferancestor configuration before falling back to the


More information about the Mercurial-devel mailing list