# HG changeset patch # User Yuya Nishihara # Date 1438951178 -32400 # Node ID 44da63623fca09d1c7f04e9068ca9f4de6781069 # Parent 996102be8b91958a65be1515424af1b655ef0d7e revset: add matchany() to construct OR expression from a list of specs This will allow us to optimize "-rREV1 -rREV2 ..." command-line options. diff -r 996102be8b91 -r 44da63623fca mercurial/revset.py --- 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)