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

login
register
mail settings
Submitter Sean Farley
Date May 27, 2018, 11:48 a.m.
Message ID <000e9442997b1c61ae02.1527421697@1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa>
Download mbox | patch
Permalink /patch/31889/
State New
Headers show

Comments

Sean Farley - May 27, 2018, 11:48 a.m.
# HG changeset patch
# User Sean Farley <sean@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.

Patch

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