mercurial/revlog.py
changeset 3923 27230c29bfec
parent 3755 05120e210c65
child 3928 4df475e22248
child 4215 90bb1ab53a85
--- a/mercurial/revlog.py	Sat Dec 16 23:33:24 2006 +0100
+++ b/mercurial/revlog.py	Sun Dec 17 05:00:22 2006 +0100
@@ -717,15 +717,19 @@
         assert heads
         return (orderedout, roots, heads)
 
-    def heads(self, start=None):
+    def heads(self, start=None, stop=None):
         """return the list of all nodes that have no children
 
         if start is specified, only heads that are descendants of
         start will be returned
-
+        if stop is specified, it will consider all the revs from stop
+        as if they had no children
         """
         if start is None:
             start = nullid
+        if stop is None:
+            stop = []
+        stoprevs = dict.fromkeys([self.rev(n) for n in stop])
         startrev = self.rev(start)
         reachable = {startrev: 1}
         heads = {startrev: 1}
@@ -734,10 +738,12 @@
         for r in xrange(startrev + 1, self.count()):
             for p in parentrevs(r):
                 if p in reachable:
-                    reachable[r] = 1
+                    if r not in stoprevs:
+                        reachable[r] = 1
                     heads[r] = 1
-                if p in heads:
+                if p in heads and p not in stoprevs:
                     del heads[p]
+
         return [self.node(r) for r in heads]
 
     def children(self, node):