diff mercurial/fileset.py @ 38844:d82c4d42b615

fileset: flatten 'or' nodes to unnest unionmatchers This also makes it easier to compile a union of basic patterns into a single regexp pattern.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 21 Jul 2018 15:23:56 +0900
parents 4dc498d61d86
children b9162ea1b815
line wrap: on
line diff
--- a/mercurial/fileset.py	Sat Jul 21 15:14:38 2018 +0900
+++ b/mercurial/fileset.py	Sat Jul 21 15:23:56 2018 +0900
@@ -103,7 +103,7 @@
     tree, pos = p.parse(tokenize(expr))
     if pos != len(expr):
         raise error.ParseError(_("invalid token"), pos)
-    return parser.simplifyinfixops(tree, {'list'})
+    return parser.simplifyinfixops(tree, {'list', 'or'})
 
 def getsymbol(x):
     if x and x[0] == 'symbol':
@@ -157,10 +157,9 @@
     ym = getmatch(mctx, y)
     return matchmod.intersectmatchers(xm, ym)
 
-def ormatch(mctx, x, y):
-    xm = getmatch(mctx, x)
-    ym = getmatch(mctx, y)
-    return matchmod.unionmatcher([xm, ym])
+def ormatch(mctx, *xs):
+    ms = [getmatch(mctx, x) for x in xs]
+    return matchmod.unionmatcher(ms)
 
 def notmatch(mctx, x):
     m = getmatch(mctx, x)