Mercurial > hg
changeset 25927:44da63623fca
revset: add matchany() to construct OR expression from a list of specs
This will allow us to optimize "-rREV1 -rREV2 ..." command-line options.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 07 Aug 2015 21:39:38 +0900 |
parents | 996102be8b91 |
children | 4ee4f7415095 |
files | mercurial/revset.py |
diffstat | 1 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Fri Aug 07 21:31:16 2015 +0900 +++ b/mercurial/revset.py Fri Aug 07 21:39:38 2015 +0900 @@ -2669,6 +2669,24 @@ tree = parse(spec, lookup) return _makematcher(ui, tree, repo) +def matchany(ui, specs, repo=None): + """Create a matcher that will include any revisions matching one of the + given specs""" + if not specs: + def mfunc(repo, subset=None): + return baseset() + return mfunc + if not all(specs): + raise error.ParseError(_("empty query")) + lookup = None + if repo: + lookup = repo.__contains__ + if len(specs) == 1: + tree = parse(specs[0], lookup) + else: + tree = ('or',) + tuple(parse(s, lookup) for s in specs) + return _makematcher(ui, tree, repo) + def _makematcher(ui, tree, repo): if ui: tree = findaliases(ui, tree, showwarning=ui.warn)