Mercurial > hg-stable
changeset 17012:ea97744c4801
localrepo: convert _updatebranchcache from nodespace to revspace
_updatebranchcache used to use revlog.reachable. After the switch to
revlog.ancestors, we can now clean it up a bit and switch the algorithm from
nodes to revs.
author | Joshua Redstone <joshua.redstone@fb.com> |
---|---|
date | Fri, 01 Jun 2012 08:56:17 -0700 |
parents | 25f7d40fe735 |
children | c8eda7bbdcab |
files | mercurial/localrepo.py |
diffstat | 1 files changed, 16 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Fri Jun 08 14:23:31 2012 -0700 +++ b/mercurial/localrepo.py Fri Jun 01 08:56:17 2012 -0700 @@ -574,29 +574,26 @@ # collect new branch entries newbranches = {} for c in ctxgen: - newbranches.setdefault(c.branch(), []).append(c.node()) + newbranches.setdefault(c.branch(), []).append(c.rev()) # if older branchheads are reachable from new ones, they aren't # really branchheads. Note checking parents is insufficient: # 1 (branch a) -> 2 (branch b) -> 3 (branch a) - for branch, newnodes in newbranches.iteritems(): - bheads = partial.setdefault(branch, []) - bheads.extend(newnodes) - if len(bheads) <= 1: - continue - bheads = sorted(bheads, key=lambda x: self[x].rev()) - # starting from tip means fewer passes over reachable - while newnodes: - latest = newnodes.pop() - if latest not in bheads: + for branch, newrevs in newbranches.iteritems(): + bheadrevs = [self.changelog.rev(node) for node in + partial.setdefault(branch, [])] + bheadrevs.extend(newrevs) + bheadrevs.sort() + # starting from tip means fewer passes over ancestors + newrevs.sort() + while newrevs: + latest = newrevs.pop() + if latest not in bheadrevs: continue - minbhnode = self[bheads[0]].node() - cl = self.changelog - ancestors = cl.ancestors([cl.rev(latest)], - cl.rev(minbhnode)) - reachable = [cl.node(rev) for rev in ancestors] - if reachable: - bheads = [b for b in bheads if b not in reachable] - partial[branch] = bheads + ancestors = set(self.changelog.ancestors([latest], + bheadrevs[0])) + if ancestors: + bheadrevs = [b for b in bheadrevs if b not in ancestors] + partial[branch] = [self.changelog.node(rev) for rev in bheadrevs] def lookup(self, key): return self[key].node()