revlog: implement a fast path for heads
authorMatt Mackall <mpm@selenic.com>
Mon, 23 Jul 2007 20:44:08 -0500
changeset 4991 9c8c42bcf17a
parent 4990 4491125c0f21
child 4992 0a676643687b
revlog: implement a fast path for heads
mercurial/revlog.py
--- a/mercurial/revlog.py	Mon Jul 23 20:44:08 2007 -0500
+++ b/mercurial/revlog.py	Mon Jul 23 20:44:08 2007 -0500
@@ -733,6 +733,17 @@
         if stop is specified, it will consider all the revs from stop
         as if they had no children
         """
+        if start is None and stop is None:
+            count = self.count()
+            if not count:
+                return [nullid]
+            ishead = [1] * (count + 1)
+            index = self.index
+            for r in xrange(count):
+                e = index[r]
+                ishead[e[5]] = ishead[e[6]] = 0
+            return [self.node(r) for r in xrange(count) if ishead[r]]
+
         if start is None:
             start = nullid
         if stop is None: