[PATCH 4 of 8 clfilter-part1] clfilter: handle non contiguous iteration in `revlov.headrevs`
pierre-yves.david at logilab.fr
pierre-yves.david at logilab.fr
Thu Sep 20 12:12:11 CDT 2012
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1346674365 -7200
# Node ID 90376bfc2f426a89571a1d6cb05ad068a4f512c1
# Parent 2127a50786c9a765776e77044d3e9fa3790ec6ff
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.
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -609,16 +609,18 @@ class revlog(object):
except AttributeError:
pass
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
if start is specified, only heads that are descendants of
More information about the Mercurial-devel
mailing list