changeset 2490:6ff82ec1f4b8

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
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Tue, 20 Jun 2006 15:02:23 -0300
parents 568e58eed096
children ffde9eb23f59
files mercurial/revlog.py
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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"""