fileset: flatten arguments list
authorYuya Nishihara <yuya@tcha.org>
Sat, 21 Jul 2018 15:14:38 +0900
changeset 38803 4dc498d61d86
parent 38802 f0a574dbfae9
child 38804 d82c4d42b615
fileset: flatten arguments list Just prepares for flattening 'or' nodes. This change would have no impact on performance.
mercurial/fileset.py
tests/test-fileset.t
--- a/mercurial/fileset.py	Sat Jul 21 15:05:40 2018 +0900
+++ b/mercurial/fileset.py	Sat Jul 21 15:14:38 2018 +0900
@@ -103,7 +103,7 @@
     tree, pos = p.parse(tokenize(expr))
     if pos != len(expr):
         raise error.ParseError(_("invalid token"), pos)
-    return tree
+    return parser.simplifyinfixops(tree, {'list'})
 
 def getsymbol(x):
     if x and x[0] == 'symbol':
@@ -131,7 +131,7 @@
     if not x:
         return []
     if x[0] == 'list':
-        return getlist(x[1]) + [x[2]]
+        return list(x[1:])
     return [x]
 
 def getargs(x, min, max, err):
@@ -174,7 +174,7 @@
 def negatematch(mctx, x):
     raise error.ParseError(_("can't use negate operator in this context"))
 
-def listmatch(mctx, x, y):
+def listmatch(mctx, *xs):
     raise error.ParseError(_("can't use a list in this context"),
                            hint=_('see hg help "filesets.x or y"'))
 
--- a/tests/test-fileset.t	Sat Jul 21 15:05:40 2018 +0900
+++ b/tests/test-fileset.t	Sat Jul 21 15:14:38 2018 +0900
@@ -111,6 +111,15 @@
       None))
   hg: parse error: can't use negate operator in this context
   [255]
+  $ fileset -p parsed 'a, b, c'
+  * parsed:
+  (list
+    (symbol 'a')
+    (symbol 'b')
+    (symbol 'c'))
+  hg: parse error: can't use a list in this context
+  (see hg help "filesets.x or y")
+  [255]
 
   $ fileset '"path":.'
   hg: parse error: not a symbol