changeset 25252:ac381dd7a21f

fileset: move validation of incomplete parsing to parse() function fileset.parse() should be responsible for all parsing errors as well.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 26 Apr 2015 19:50:42 +0900
parents 235f6490550c
children 3f1a9b44b8c2
files mercurial/commands.py mercurial/fileset.py
diffstat 2 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sun Apr 26 19:42:47 2015 +0900
+++ b/mercurial/commands.py	Sun Apr 26 19:50:42 2015 +0900
@@ -2164,7 +2164,7 @@
     '''parse and apply a fileset specification'''
     ctx = scmutil.revsingle(repo, opts.get('rev'), None)
     if ui.verbose:
-        tree = fileset.parse(expr)[0]
+        tree = fileset.parse(expr)
         ui.note(tree, "\n")
 
     for f in ctx.getfileset(expr):
--- a/mercurial/fileset.py	Sun Apr 26 19:42:47 2015 +0900
+++ b/mercurial/fileset.py	Sun Apr 26 19:50:42 2015 +0900
@@ -81,7 +81,10 @@
 
 def parse(expr):
     p = parser.parser(tokenize, elements)
-    return p.parse(expr)
+    tree, pos = p.parse(expr)
+    if pos != len(expr):
+        raise error.ParseError(_("invalid token"), pos)
+    return tree
 
 def getstring(x, err):
     if x and (x[0] == 'string' or x[0] == 'symbol'):
@@ -491,9 +494,7 @@
 ]
 
 def getfileset(ctx, expr):
-    tree, pos = parse(expr)
-    if (pos != len(expr)):
-        raise error.ParseError(_("invalid token"), pos)
+    tree = parse(expr)
 
     # do we need status info?
     if (_intree(['modified', 'added', 'removed', 'deleted',