revset: add matchany() to construct OR expression from a list of specs
This will allow us to optimize "-rREV1 -rREV2 ..." command-line options.
--- 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)