##// END OF EJS Templates
revrange: drop old-style parser in favor of revset (API)...
Yuya Nishihara -
r25904:fbaa2de1 default
parent child Browse files
Show More
@@ -6,7 +6,7 b''
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from i18n import _
9 from mercurial.node import nullrev, wdirrev
9 from mercurial.node import wdirrev
10 10 import util, error, osutil, revset, similar, encoding, phases
11 11 import pathutil
12 12 import match as matchmod
@@ -720,54 +720,10 b' def revpair(repo, revs):'
720 720
721 721 def revrange(repo, revs):
722 722 """Yield revision as strings from a list of revision specifications."""
723
724 def revfix(repo, val, defval):
725 if not val and val != 0 and defval is not None:
726 return defval
727 return repo[val].rev()
728
729 723 subsets = []
730
731 revsetaliases = [alias for (alias, _) in
732 repo.ui.configitems("revsetalias")]
733
734 724 for spec in revs:
735 # attempt to parse old-style ranges first to deal with
736 # things like old-tag which contain query metacharacters
737 try:
738 # ... except for revset aliases without arguments. These
739 # should be parsed as soon as possible, because they might
740 # clash with a hash prefix.
741 if spec in revsetaliases:
742 raise error.RepoLookupError
743
744 if isinstance(spec, int):
745 subsets.append(revset.baseset([spec]))
746 continue
747
748 if _revrangesep in spec:
749 start, end = spec.split(_revrangesep, 1)
750 if start in revsetaliases or end in revsetaliases:
751 raise error.RepoLookupError
752
753 start = revfix(repo, start, 0)
754 end = revfix(repo, end, len(repo) - 1)
755 if end == nullrev and start < 0:
756 start = nullrev
757 if start < end:
758 l = revset.spanset(repo, start, end + 1)
759 else:
760 l = revset.spanset(repo, start, end - 1)
761 subsets.append(l)
762 continue
763 elif spec and spec in repo: # single unquoted rev
764 rev = revfix(repo, spec, None)
765 subsets.append(revset.baseset([rev]))
766 continue
767 except error.RepoLookupError:
768 pass
769
770 # fall through to new-style queries if old-style fails
725 if isinstance(spec, int):
726 spec = revset.formatspec('rev(%d)', spec)
771 727 m = revset.match(repo.ui, spec, repo)
772 728 subsets.append(m(repo))
773 729
General Comments 0
You need to be logged in to leave comments. Login now