mercurial/fileset.py
changeset 38803 4dc498d61d86
parent 38772 af5c0c933af8
child 38804 d82c4d42b615
equal deleted inserted replaced
38802:f0a574dbfae9 38803:4dc498d61d86
   101 def parse(expr):
   101 def parse(expr):
   102     p = parser.parser(elements)
   102     p = parser.parser(elements)
   103     tree, pos = p.parse(tokenize(expr))
   103     tree, pos = p.parse(tokenize(expr))
   104     if pos != len(expr):
   104     if pos != len(expr):
   105         raise error.ParseError(_("invalid token"), pos)
   105         raise error.ParseError(_("invalid token"), pos)
   106     return tree
   106     return parser.simplifyinfixops(tree, {'list'})
   107 
   107 
   108 def getsymbol(x):
   108 def getsymbol(x):
   109     if x and x[0] == 'symbol':
   109     if x and x[0] == 'symbol':
   110         return x[1]
   110         return x[1]
   111     raise error.ParseError(_('not a symbol'))
   111     raise error.ParseError(_('not a symbol'))
   129 
   129 
   130 def getlist(x):
   130 def getlist(x):
   131     if not x:
   131     if not x:
   132         return []
   132         return []
   133     if x[0] == 'list':
   133     if x[0] == 'list':
   134         return getlist(x[1]) + [x[2]]
   134         return list(x[1:])
   135     return [x]
   135     return [x]
   136 
   136 
   137 def getargs(x, min, max, err):
   137 def getargs(x, min, max, err):
   138     l = getlist(x)
   138     l = getlist(x)
   139     if len(l) < min or len(l) > max:
   139     if len(l) < min or len(l) > max:
   172     return matchmod.differencematcher(xm, ym)
   172     return matchmod.differencematcher(xm, ym)
   173 
   173 
   174 def negatematch(mctx, x):
   174 def negatematch(mctx, x):
   175     raise error.ParseError(_("can't use negate operator in this context"))
   175     raise error.ParseError(_("can't use negate operator in this context"))
   176 
   176 
   177 def listmatch(mctx, x, y):
   177 def listmatch(mctx, *xs):
   178     raise error.ParseError(_("can't use a list in this context"),
   178     raise error.ParseError(_("can't use a list in this context"),
   179                            hint=_('see hg help "filesets.x or y"'))
   179                            hint=_('see hg help "filesets.x or y"'))
   180 
   180 
   181 def func(mctx, a, b):
   181 def func(mctx, a, b):
   182     funcname = getsymbol(a)
   182     funcname = getsymbol(a)