[PATCH 1 of 2] Add revlog.parentrevs function

Alexis S. L. Carvalho alexis at cecm.usp.br
Tue Jun 20 14:10:02 CDT 2006


# HG changeset patch
# User Alexis S. L. Carvalho <alexis at cecm.usp.br>
# Date 1150826250 10800
# Node ID 6f4d04f79b2da53783942cf141d65f9b1f93f02e
# Parent  ff9ee834e3b6f0c151f920288cdcfc62bbd2ff80
Add revlog.parentrevs function.

This allows one to walk the revision graph using only revision numbers,
which can be faster than using revision hashes, especially for
RevlogNG, where the parents of a revision are stored as revision
numbers.

diff -r ff9ee834e3b6 -r 6f4d04f79b2d mercurial/revlog.py
--- a/mercurial/revlog.py	Tue Jun 20 09:11:41 2006 -0700
+++ b/mercurial/revlog.py	Tue Jun 20 14:57:30 2006 -0300
@@ -477,6 +477,13 @@ class revlog(object):
         if self.version == REVLOGV0:
             return d
         return [ self.node(x) for x in d ]
+    def parentrevs(self, rev):
+        if rev == -1:
+            return (-1, -1)
+        d = self.index[rev][-3:-1]
+        if self.version == REVLOGV0:
+            return [ self.rev(x) for x in d ]
+        return d
     def start(self, rev):
         if rev < 0:
             return -1


More information about the Mercurial mailing list