clfilter: handle non contiguous iteration in `revlov.headrevs`
This prepares changelog level filtering. We can't assume that any revision can
be heads because filtered revisions need to be excluded.
New algorithm:
- All revisions now start as "non heads",
- every revision we iterate over is made candidate head,
- parents of iterated revisions are definitely not head.
Filtered revisions are never iterated over and never considered as candidate
head.
--- a/mercurial/revlog.py Thu Sep 20 19:00:59 2012 +0200
+++ b/mercurial/revlog.py Mon Sep 03 14:12:45 2012 +0200
@@ -611,12 +611,14 @@
count = len(self)
if not count:
return [nullrev]
- ishead = [1] * (count + 1)
+ # we won't iter over filtered rev so nobody is a head at start
+ ishead = [0] * (count + 1)
index = self.index
for r in self:
+ ishead[r] = 1 # I may be an head
e = index[r]
- ishead[e[5]] = ishead[e[6]] = 0
- return [r for r in xrange(count) if ishead[r]]
+ ishead[e[5]] = ishead[e[6]] = 0 # my parent are not
+ return [r for r, val in enumerate(ishead) if val]
def heads(self, start=None, stop=None):
"""return the list of all nodes that have no children