[PATCH 2 of 2] revset: have rev() validate input by repo.__contains__()

Yuya Nishihara yuya at tcha.org
Mon Feb 2 08:15:40 CST 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1420884012 -32400
#      Sat Jan 10 19:00:12 2015 +0900
# Node ID d247b985ebc0acdb837bc89288c8569151446620
# Parent  184aa519a7a72ab10361d91f66455e3cea8f4f50
revset: have rev() validate input by repo.__contains__()

fullreposet.__contains__() will be rewritten in order to support "null"
revision, so "rev()" can't rely on it.

"l in repo" is slightly slower than "l in fullreposet(repo)", but I think
the difference is acceptable.

revisions:
0) 0c4419faacbc "l not in fullreposet(repo) and l != node.nullrev"
1) this patch "l not in repo"

revset #0: rev(210000)
0) wall 0.000055 comb 0.000000 user 0.000000 sys 0.000000 (best of 43173)
1) wall 0.000067 comb 0.000000 user 0.000000 sys 0.000000 (best of 40090)

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1547,7 +1547,7 @@ def rev(repo, subset, x):
     except (TypeError, ValueError):
         # i18n: "rev" is a keyword
         raise error.ParseError(_("rev expects a number"))
-    if l not in fullreposet(repo) and l != node.nullrev:
+    if l not in repo:
         return baseset()
     return subset & baseset([l])
 


More information about the Mercurial-devel mailing list