Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 31025:6cf2857526c7
scmutil: proxy revrange() through repo to break import cycles
This was one of the hardest import cycles as scmutil is widely used and
revset functions are likely to depend on a variety of modules.
New repo.anyrevs() does not expand user aliases by default to copy the
behavior of the existing repo.revs(). I don't want to add new function to
localrepository, but this function is quite similar to repo.revs() so it
won't increase the complexity of the localrepository class so much.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 19 Feb 2017 20:00:18 +0900 |
parents | 0b8356705de6 |
children | 59e69ed81776 |
comparison
equal
deleted
inserted
replaced
31024:0b8356705de6 | 31025:6cf2857526c7 |
---|---|
575 | 575 |
576 The revset is specified as a string ``expr`` that may contain | 576 The revset is specified as a string ``expr`` that may contain |
577 %-formatting to escape certain types. See ``revsetlang.formatspec``. | 577 %-formatting to escape certain types. See ``revsetlang.formatspec``. |
578 | 578 |
579 Revset aliases from the configuration are not expanded. To expand | 579 Revset aliases from the configuration are not expanded. To expand |
580 user aliases, consider calling ``scmutil.revrange()``. | 580 user aliases, consider calling ``scmutil.revrange()`` or |
581 ``repo.anyrevs([expr], user=True)``. | |
581 | 582 |
582 Returns a revset.abstractsmartset, which is a list-like interface | 583 Returns a revset.abstractsmartset, which is a list-like interface |
583 that contains integer revisions. | 584 that contains integer revisions. |
584 ''' | 585 ''' |
585 expr = revsetlang.formatspec(expr, *args) | 586 expr = revsetlang.formatspec(expr, *args) |
595 Revset aliases from the configuration are not expanded. To expand | 596 Revset aliases from the configuration are not expanded. To expand |
596 user aliases, consider calling ``scmutil.revrange()``. | 597 user aliases, consider calling ``scmutil.revrange()``. |
597 ''' | 598 ''' |
598 for r in self.revs(expr, *args): | 599 for r in self.revs(expr, *args): |
599 yield self[r] | 600 yield self[r] |
601 | |
602 def anyrevs(self, specs, user=False): | |
603 '''Find revisions matching one of the given revsets. | |
604 | |
605 Revset aliases from the configuration are not expanded by default. To | |
606 expand user aliases, specify ``user=True``. | |
607 ''' | |
608 if user: | |
609 m = revset.matchany(self.ui, specs, repo=self) | |
610 else: | |
611 m = revset.matchany(None, specs) | |
612 return m(self) | |
600 | 613 |
601 def url(self): | 614 def url(self): |
602 return 'file:' + self.root | 615 return 'file:' + self.root |
603 | 616 |
604 def hook(self, name, throw=False, **args): | 617 def hook(self, name, throw=False, **args): |