# HG changeset patch # User Sune Foldager # Date 1269619343 -3600 # Node ID fe39f0160c74315b70d02f3b423f86c39f4342b7 # Parent 95b7a15b2f057ee31a98ac9e581077c5ce9fdf16 localrepo: change _updatebranchcache to use a context generator diff -r 95b7a15b2f05 -r fe39f0160c74 hgext/mq.py --- a/hgext/mq.py Wed Mar 24 19:44:30 2010 +0100 +++ b/hgext/mq.py Fri Mar 26 17:02:23 2010 +0100 @@ -2603,7 +2603,8 @@ start = lrev + 1 if start < qbase: # update the cache (excluding the patches) and save it - self._updatebranchcache(partial, lrev + 1, qbase) + ctxgen = (self[r] for r in xrange(lrev + 1, qbase)) + self._updatebranchcache(partial, ctxgen) self._writebranchcache(partial, cl.node(qbase - 1), qbase - 1) start = qbase # if start = qbase, the cache is as updated as it should be. @@ -2611,7 +2612,8 @@ # we might as well use it, but we won't save it. # update the cache up to the tip - self._updatebranchcache(partial, start, len(cl)) + ctxgen = (self[r] for r in xrange(start, len(cl))) + self._updatebranchcache(partial, ctxgen) return partial diff -r 95b7a15b2f05 -r fe39f0160c74 mercurial/localrepo.py --- 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: