# HG changeset patch # User Alexis S. L. Carvalho # Date 1150826543 10800 # Node ID 6ff82ec1f4b8b464e64a695e965dbec93057a894 # Parent 568e58eed096e832cc1a2f02b70b80a4ea9cac99 Change revlog.heads to walk the revision graph using revision numbers On the kernel repo: $ hg heads -q before after RevlogNG 1.11 0.52 Revlogv0 0.80 0.69 Since the current code for tags has to find all the heads of the repo, this also helps there: $ hg tags before after RevlogNG 2.35 1.76 Revlogv0 2.04 1.90 diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -713,19 +713,19 @@ class revlog(object): """ if start is None: start = nullid - reachable = {start: 1} - heads = {start: 1} startrev = self.rev(start) + reachable = {startrev: 1} + heads = {startrev: 1} + parentrevs = self.parentrevs for r in xrange(startrev + 1, self.count()): - n = self.node(r) - for pn in self.parents(n): - if pn in reachable: - reachable[n] = 1 - heads[n] = 1 - if pn in heads: - del heads[pn] - return heads.keys() + for p in parentrevs(r): + if p in reachable: + reachable[r] = 1 + heads[r] = 1 + if p in heads: + del heads[p] + return [self.node(r) for r in heads] def children(self, node): """find the children of a given node"""