Patchwork [4,of,9,cah] revlog: introduce commonancestorsheads method

login
register
mail settings
Submitter Mads Kiilerich
Date April 17, 2014, 6:07 p.m.
Message ID <40ace21cb3a1716c8c68.1397758076@localhost.localdomain>
Download mbox | patch
Permalink /patch/4397/
State Accepted
Commit 40ace21cb3a1716c8c686874dcbca47a53a84964
Headers show

Comments

Mads Kiilerich - April 17, 2014, 6:07 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1397757695 -7200
#      Thu Apr 17 20:01:35 2014 +0200
# Node ID 40ace21cb3a1716c8c686874dcbca47a53a84964
# Parent  628c16489d1cec98f0f43a784375ff4fefb0dc52
revlog: introduce commonancestorsheads method

Very similar to commonancestors but giving all the common ancestors heads.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -734,6 +734,15 @@  class revlog(object):
                 break
         return False
 
+    def commonancestorsheads(self, a, b):
+        """calculate all the heads of the common ancestors of nodes a and b"""
+        a, b = self.rev(a), self.rev(b)
+        try:
+            ancs = self.index.commonancestorsheads(a, b)
+        except (AttributeError, OverflowError): # C implementation failed
+            ancs = ancestor.commonancestorsheads(self.parentrevs, a, b)
+        return map(self.node, ancs)
+
     def commonancestors(self, a, b):
         """calculate the least common ancestors of nodes a and b"""
         a, b = self.rev(a), self.rev(b)