Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 44584:f913ece27ff5
revset: leverage internal _rev() function to implement rev()
Now 'rev(n)' is identical to 'present(_rev(n))'.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 21 Mar 2020 13:42:08 +0900 |
parents | 967e2e81f762 |
children | 48b99af7b4b3 |
comparison
equal
deleted
inserted
replaced
44583:967e2e81f762 | 44584:f913ece27ff5 |
---|---|
2080 return checkstatus(repo, subset, pat, 2) | 2080 return checkstatus(repo, subset, pat, 2) |
2081 | 2081 |
2082 | 2082 |
2083 @predicate(b'rev(number)', safe=True) | 2083 @predicate(b'rev(number)', safe=True) |
2084 def rev(repo, subset, x): | 2084 def rev(repo, subset, x): |
2085 """Revision with the given numeric identifier. | 2085 """Revision with the given numeric identifier.""" |
2086 """ | |
2087 # i18n: "rev" is a keyword | |
2088 l = getargs(x, 1, 1, _(b"rev requires one argument")) | |
2089 try: | 2086 try: |
2090 # i18n: "rev" is a keyword | 2087 return _rev(repo, subset, x) |
2091 l = int(getstring(l[0], _(b"rev requires a number"))) | 2088 except error.RepoLookupError: |
2092 except (TypeError, ValueError): | |
2093 # i18n: "rev" is a keyword | |
2094 raise error.ParseError(_(b"rev expects a number")) | |
2095 if l not in repo.changelog and l not in _virtualrevs: | |
2096 return baseset() | 2089 return baseset() |
2097 return subset & baseset([l]) | |
2098 | 2090 |
2099 | 2091 |
2100 @predicate(b'_rev(number)', safe=True) | 2092 @predicate(b'_rev(number)', safe=True) |
2101 def _rev(repo, subset, x): | 2093 def _rev(repo, subset, x): |
2102 # internal version of "rev(x)" that raise error if "x" is invalid | 2094 # internal version of "rev(x)" that raise error if "x" is invalid |