Change revlog.heads to walk the revision graph using revision numbers
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Tue, 20 Jun 2006 15:02:23 -0300
changeset 2490 6ff82ec1f4b8
parent 2489 568e58eed096
child 2491 ffde9eb23f59
Change revlog.heads to walk the revision graph using revision numbers On the kernel repo: $ hg heads -q before after RevlogNG 1.11 0.52 Revlogv0 0.80 0.69 Since the current code for tags has to find all the heads of the repo, this also helps there: $ hg tags before after RevlogNG 2.35 1.76 Revlogv0 2.04 1.90
mercurial/revlog.py
--- a/mercurial/revlog.py	Tue Jun 20 14:57:30 2006 -0300
+++ b/mercurial/revlog.py	Tue Jun 20 15:02:23 2006 -0300
@@ -713,19 +713,19 @@
         """
         if start is None:
             start = nullid
-        reachable = {start: 1}
-        heads = {start: 1}
         startrev = self.rev(start)
+        reachable = {startrev: 1}
+        heads = {startrev: 1}
 
+        parentrevs = self.parentrevs
         for r in xrange(startrev + 1, self.count()):
-            n = self.node(r)
-            for pn in self.parents(n):
-                if pn in reachable:
-                    reachable[n] = 1
-                    heads[n] = 1
-                if pn in heads:
-                    del heads[pn]
-        return heads.keys()
+            for p in parentrevs(r):
+                if p in reachable:
+                    reachable[r] = 1
+                    heads[r] = 1
+                if p in heads:
+                    del heads[p]
+        return [self.node(r) for r in heads]
 
     def children(self, node):
         """find the children of a given node"""