diff mercurial/revset.py @ 25251:235f6490550c

revset: move validation of incomplete parsing to parse() function revset.parse() should be responsible for all parsing errors. Perhaps it wasn't because 'revset.parse' was not a real function when the validation code was added at ffcb7e4d719f.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 26 Apr 2015 19:42:47 +0900
parents 57fae767c52b
children 3f1a9b44b8c2
line wrap: on
line diff
--- a/mercurial/revset.py	Fri May 22 14:39:34 2015 -0700
+++ b/mercurial/revset.py	Sun Apr 26 19:42:47 2015 +0900
@@ -2509,7 +2509,10 @@
 
 def parse(spec, lookup=None):
     p = parser.parser(tokenize, elements)
-    return p.parse(spec, lookup=lookup)
+    tree, pos = p.parse(spec, lookup=lookup)
+    if pos != len(spec):
+        raise error.ParseError(_("invalid token"), pos)
+    return tree
 
 def posttreebuilthook(tree, repo):
     # hook for extensions to execute code on the optimized tree
@@ -2521,9 +2524,7 @@
     lookup = None
     if repo:
         lookup = repo.__contains__
-    tree, pos = parse(spec, lookup)
-    if (pos != len(spec)):
-        raise error.ParseError(_("invalid token"), pos)
+    tree = parse(spec, lookup)
     if ui:
         tree = findaliases(ui, tree, showwarning=ui.warn)
     tree = foldconcat(tree)