comparison mercurial/revset.py @ 37350:e32dfff71529

revset: use revsymbol() for checking if a symbol is valid Differential Revision: https://phab.mercurial-scm.org/D3078
author Martin von Zweigbergk <martinvonz@google.com>
date Sun, 01 Apr 2018 22:48:32 -0700
parents 0194dac77c93
children bef863a09acd
comparison
equal deleted inserted replaced
37349:36b2a304216c 37350:e32dfff71529
2168 2168
2169 def posttreebuilthook(tree, repo): 2169 def posttreebuilthook(tree, repo):
2170 # hook for extensions to execute code on the optimized tree 2170 # hook for extensions to execute code on the optimized tree
2171 pass 2171 pass
2172 2172
2173 def lookupfn(repo):
2174 return lambda symbol: scmutil.isrevsymbol(repo, symbol)
2175
2173 def match(ui, spec, repo=None): 2176 def match(ui, spec, repo=None):
2174 """Create a matcher for a single revision spec""" 2177 """Create a matcher for a single revision spec"""
2175 return matchany(ui, [spec], repo=repo) 2178 return matchany(ui, [spec], repo=repo)
2176 2179
2177 def matchany(ui, specs, repo=None, localalias=None): 2180 def matchany(ui, specs, repo=None, localalias=None):
2187 return mfunc 2190 return mfunc
2188 if not all(specs): 2191 if not all(specs):
2189 raise error.ParseError(_("empty query")) 2192 raise error.ParseError(_("empty query"))
2190 lookup = None 2193 lookup = None
2191 if repo: 2194 if repo:
2192 lookup = repo.__contains__ 2195 lookup = lookupfn(repo)
2193 if len(specs) == 1: 2196 if len(specs) == 1:
2194 tree = revsetlang.parse(specs[0], lookup) 2197 tree = revsetlang.parse(specs[0], lookup)
2195 else: 2198 else:
2196 tree = ('or', 2199 tree = ('or',
2197 ('list',) + tuple(revsetlang.parse(s, lookup) for s in specs)) 2200 ('list',) + tuple(revsetlang.parse(s, lookup) for s in specs))