changeset 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 2d63a8910db6
files mercurial/revset.py
diffstat 1 files changed, 3 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Sat Mar 21 13:39:39 2020 +0900
+++ b/mercurial/revset.py	Sat Mar 21 13:42:08 2020 +0900
@@ -2082,19 +2082,11 @@
 
 @predicate(b'rev(number)', safe=True)
 def rev(repo, subset, x):
-    """Revision with the given numeric identifier.
-    """
-    # i18n: "rev" is a keyword
-    l = getargs(x, 1, 1, _(b"rev requires one argument"))
+    """Revision with the given numeric identifier."""
     try:
-        # i18n: "rev" is a keyword
-        l = int(getstring(l[0], _(b"rev requires a number")))
-    except (TypeError, ValueError):
-        # i18n: "rev" is a keyword
-        raise error.ParseError(_(b"rev expects a number"))
-    if l not in repo.changelog and l not in _virtualrevs:
+        return _rev(repo, subset, x)
+    except error.RepoLookupError:
         return baseset()
-    return subset & baseset([l])
 
 
 @predicate(b'_rev(number)', safe=True)