diff mercurial/revlog.py @ 3925:27230c29bfec 0.9.3

fix calculation of new heads added during push with -r fix issue450
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sun, 17 Dec 2006 05:00:22 +0100
parents 05120e210c65
children 4df475e22248 90bb1ab53a85
line wrap: on
line diff
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -717,15 +717,19 @@ class revlog(object):
         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 @@ class revlog(object):
         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):