##// END OF EJS Templates
localrepo: change _updatebranchcache to use a context generator
Sune Foldager -
r10770:fe39f016 stable
parent child Browse files
Show More
@@ -2603,7 +2603,8 b' def reposetup(ui, repo):'
2603 start = lrev + 1
2603 start = lrev + 1
2604 if start < qbase:
2604 if start < qbase:
2605 # update the cache (excluding the patches) and save it
2605 # update the cache (excluding the patches) and save it
2606 self._updatebranchcache(partial, lrev + 1, qbase)
2606 ctxgen = (self[r] for r in xrange(lrev + 1, qbase))
2607 self._updatebranchcache(partial, ctxgen)
2607 self._writebranchcache(partial, cl.node(qbase - 1), qbase - 1)
2608 self._writebranchcache(partial, cl.node(qbase - 1), qbase - 1)
2608 start = qbase
2609 start = qbase
2609 # if start = qbase, the cache is as updated as it should be.
2610 # if start = qbase, the cache is as updated as it should be.
@@ -2611,7 +2612,8 b' def reposetup(ui, repo):'
2611 # we might as well use it, but we won't save it.
2612 # we might as well use it, but we won't save it.
2612
2613
2613 # update the cache up to the tip
2614 # update the cache up to the tip
2614 self._updatebranchcache(partial, start, len(cl))
2615 ctxgen = (self[r] for r in xrange(start, len(cl)))
2616 self._updatebranchcache(partial, ctxgen)
2615
2617
2616 return partial
2618 return partial
2617
2619
@@ -320,7 +320,8 b' class localrepository(repo.repository):'
320 # TODO: rename this function?
320 # TODO: rename this function?
321 tiprev = len(self) - 1
321 tiprev = len(self) - 1
322 if lrev != tiprev:
322 if lrev != tiprev:
323 self._updatebranchcache(partial, lrev + 1, tiprev + 1)
323 ctxgen = (self[r] for r in xrange(lrev + 1, tiprev + 1))
324 self._updatebranchcache(partial, ctxgen)
324 self._writebranchcache(partial, self.changelog.tip(), tiprev)
325 self._writebranchcache(partial, self.changelog.tip(), tiprev)
325
326
326 return partial
327 return partial
@@ -398,11 +399,10 b' class localrepository(repo.repository):'
398 except (IOError, OSError):
399 except (IOError, OSError):
399 pass
400 pass
400
401
401 def _updatebranchcache(self, partial, start, end):
402 def _updatebranchcache(self, partial, ctxgen):
402 # collect new branch entries
403 # collect new branch entries
403 newbranches = {}
404 newbranches = {}
404 for r in xrange(start, end):
405 for c in ctxgen:
405 c = self[r]
406 newbranches.setdefault(c.branch(), []).append(c.node())
406 newbranches.setdefault(c.branch(), []).append(c.node())
407 # if older branchheads are reachable from new ones, they aren't
407 # if older branchheads are reachable from new ones, they aren't
408 # really branchheads. Note checking parents is insufficient:
408 # really branchheads. Note checking parents is insufficient:
General Comments 0
You need to be logged in to leave comments. Login now