[PATCH 1 of 3] revlog: add ancestorrev() to avoid rev/node conversions

Peter Arrenbrecht peter.arrenbrecht at gmail.com
Mon Nov 17 08:03:02 CST 2008


# HG changeset patch
# User Peter Arrenbrecht <peter.arrenbrecht at gmail.com>
# Date 1226929607 -3600
# Node ID 6cdb6107f3fd3db1656aca2b99ebd47a038bbcd7
# Parent  8119c1a607c49f4ea8968d67ab8984119fda26cf
revlog: add ancestorrev() to avoid rev/node conversions

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1107,17 +1107,21 @@
         self._cache = (node, curr, text)
         return node
 
-    def ancestor(self, a, b):
-        """calculate the least common ancestor of nodes a and b"""
+    def ancestorrev(self, a, b):
+        """calculate the least common ancestor rev of revs a and b"""
 
         def parents(rev):
             return [p for p in self.parentrevs(rev) if p != nullrev]
 
-        c = ancestor.ancestor(self.rev(a), self.rev(b), parents)
+        c = ancestor.ancestor(a, b, parents)
         if c is None:
-            return nullid
+            return nullrev
 
-        return self.node(c)
+        return c
+
+    def ancestor(self, a, b):
+        """calculate the least common ancestor of nodes a and b"""
+        return self.node(self.ancestorrev(self.rev(a), self.rev(b)))
 
     def group(self, nodelist, lookup, infocollect=None):
         """calculate a delta group


More information about the Mercurial-devel mailing list