changeset 20557:514d32de6646

revlog: introduce commonancestors method for getting all common ancestor heads
author Mads Kiilerich <madski@unity3d.com>
date Mon, 24 Feb 2014 22:42:14 +0100
parents db0740a487ab
children c4f45ce85351
files mercurial/revlog.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Mon Feb 24 22:42:14 2014 +0100
+++ b/mercurial/revlog.py	Mon Feb 24 22:42:14 2014 +0100
@@ -734,17 +734,21 @@
                 break
         return False
 
-    def ancestor(self, a, b):
-        """calculate the least common ancestor of nodes a and b"""
-
+    def commonancestors(self, a, b):
+        """calculate the least common ancestors of nodes a and b"""
         a, b = self.rev(a), self.rev(b)
         try:
             ancs = self.index.ancestors(a, b)
-        except (AttributeError, OverflowError):
+        except (AttributeError, OverflowError): # C implementation failed
             ancs = ancestor.ancestors(self.parentrevs, a, b)
+        return map(self.node, ancs)
+
+    def ancestor(self, a, b):
+        """calculate a least common ancestor of nodes a and b"""
+        ancs = self.commonancestors(a, b)
         if ancs:
             # choose a consistent winner when there's a tie
-            return min(map(self.node, ancs))
+            return min(ancs)
         return nullid
 
     def _match(self, id):