Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 10770:fe39f0160c74 stable
localrepo: change _updatebranchcache to use a context generator
author | Sune Foldager <cryo@cyanite.org> |
---|---|
date | Fri, 26 Mar 2010 17:02:23 +0100 |
parents | 00d46934ee35 |
children | 01f097c4ae66 |
line wrap: on
line diff
--- a/mercurial/localrepo.py Wed Mar 24 19:44:30 2010 +0100 +++ b/mercurial/localrepo.py Fri Mar 26 17:02:23 2010 +0100 @@ -320,7 +320,8 @@ # TODO: rename this function? tiprev = len(self) - 1 if lrev != tiprev: - self._updatebranchcache(partial, lrev + 1, tiprev + 1) + ctxgen = (self[r] for r in xrange(lrev + 1, tiprev + 1)) + self._updatebranchcache(partial, ctxgen) self._writebranchcache(partial, self.changelog.tip(), tiprev) return partial @@ -398,11 +399,10 @@ except (IOError, OSError): pass - def _updatebranchcache(self, partial, start, end): + def _updatebranchcache(self, partial, ctxgen): # collect new branch entries newbranches = {} - for r in xrange(start, end): - c = self[r] + for c in ctxgen: newbranches.setdefault(c.branch(), []).append(c.node()) # if older branchheads are reachable from new ones, they aren't # really branchheads. Note checking parents is insufficient: