Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 17675:8575f4a2126e
clfilter: remove usage of `range` in favor of iteration over changelog
If we want to apply filtering at changelog level, we need to iterate over it.
See previous changeset description for details.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Thu, 20 Sep 2012 19:01:53 +0200 |
parents | 9dbd5fa6d301 |
children | 5210e5a556d9 |
comparison
equal
deleted
inserted
replaced
17674:e69274f8d444 | 17675:8575f4a2126e |
---|---|
361 | 361 |
362 def __len__(self): | 362 def __len__(self): |
363 return len(self.changelog) | 363 return len(self.changelog) |
364 | 364 |
365 def __iter__(self): | 365 def __iter__(self): |
366 for i in xrange(len(self)): | 366 return iter(self.changelog) |
367 yield i | |
368 | 367 |
369 def revs(self, expr, *args): | 368 def revs(self, expr, *args): |
370 '''Return a list of revisions matching the given revset''' | 369 '''Return a list of revisions matching the given revset''' |
371 expr = revset.formatspec(expr, *args) | 370 expr = revset.formatspec(expr, *args) |
372 m = revset.match(None, expr) | 371 m = revset.match(None, expr) |
373 return [r for r in m(self, range(len(self)))] | 372 return [r for r in m(self, list(self))] |
374 | 373 |
375 def set(self, expr, *args): | 374 def set(self, expr, *args): |
376 ''' | 375 ''' |
377 Yield a context for each matching revision, after doing arg | 376 Yield a context for each matching revision, after doing arg |
378 replacement via revset.formatspec | 377 replacement via revset.formatspec |
601 | 600 |
602 def _branchtags(self, partial, lrev): | 601 def _branchtags(self, partial, lrev): |
603 # TODO: rename this function? | 602 # TODO: rename this function? |
604 tiprev = len(self) - 1 | 603 tiprev = len(self) - 1 |
605 if lrev != tiprev: | 604 if lrev != tiprev: |
606 ctxgen = (self[r] for r in xrange(lrev + 1, tiprev + 1)) | 605 ctxgen = (self[r] for r in self.changelog.revs(lrev + 1, tiprev)) |
607 self._updatebranchcache(partial, ctxgen) | 606 self._updatebranchcache(partial, ctxgen) |
608 self._writebranchcache(partial, self.changelog.tip(), tiprev) | 607 self._writebranchcache(partial, self.changelog.tip(), tiprev) |
609 | 608 |
610 return partial | 609 return partial |
611 | 610 |