Mercurial > hg
changeset 20779:ffc2295c6b80
revset: pass a lookup function to the tokenizer
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 18 Mar 2014 17:19:44 -0500 |
parents | 7c4778bc29f0 |
children | 403f1f73d30f |
files | mercurial/revset.py |
diffstat | 1 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Tue Mar 18 17:17:23 2014 -0500 +++ b/mercurial/revset.py Tue Mar 18 17:19:44 2014 -0500 @@ -128,7 +128,7 @@ keywords = set(['and', 'or', 'not']) -def tokenize(program): +def tokenize(program, lookup=None): ''' Parse a revset statement into a stream of tokens @@ -2023,14 +2023,17 @@ aliases[alias.name] = alias return _expandaliases(aliases, tree, [], {}) -def parse(spec): +def parse(spec, lookup=None): p = parser.parser(tokenize, elements) - return p.parse(spec) - -def match(ui, spec): + return p.parse(spec, lookup=lookup) + +def match(ui, spec, repo=None): if not spec: raise error.ParseError(_("empty query")) - tree, pos = parse(spec) + lookup = None + if repo: + lookup = repo.__contains__ + tree, pos = parse(spec, lookup) if (pos != len(spec)): raise error.ParseError(_("invalid token"), pos) if ui: