Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
10768:95b7a15b2f05 | 10770:fe39f0160c74 |
---|---|
318 | 318 |
319 def _branchtags(self, partial, lrev): | 319 def _branchtags(self, partial, lrev): |
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 |
327 | 328 |
328 def branchmap(self): | 329 def branchmap(self): |
396 f.write("%s %s\n" % (hex(node), label)) | 397 f.write("%s %s\n" % (hex(node), label)) |
397 f.rename() | 398 f.rename() |
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: |
409 # 1 (branch a) -> 2 (branch b) -> 3 (branch a) | 409 # 1 (branch a) -> 2 (branch b) -> 3 (branch a) |
410 for branch, newnodes in newbranches.iteritems(): | 410 for branch, newnodes in newbranches.iteritems(): |