comparison mercurial/revset.py @ 29418:bcefb25acf52

revset: implement match() in terms of matchany() match() is the special case of a single element list being passed to matchany() with the additional error checking that the revset spec is defined. Change the implementation to remove the redundant code and have match() call matchany().
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 25 Jun 2016 19:10:46 -0700
parents 785cadec2091
children 4f5531f8ac38
comparison
equal deleted inserted replaced
29417:526b027b0130 29418:bcefb25acf52
2526 def posttreebuilthook(tree, repo): 2526 def posttreebuilthook(tree, repo):
2527 # hook for extensions to execute code on the optimized tree 2527 # hook for extensions to execute code on the optimized tree
2528 pass 2528 pass
2529 2529
2530 def match(ui, spec, repo=None): 2530 def match(ui, spec, repo=None):
2531 """Create a matcher for a single revision spec."""
2531 if not spec: 2532 if not spec:
2532 raise error.ParseError(_("empty query")) 2533 raise error.ParseError(_("empty query"))
2533 lookup = None 2534 return matchany(ui, [spec], repo=repo)
2534 if repo:
2535 lookup = repo.__contains__
2536 tree = parse(spec, lookup)
2537 return _makematcher(ui, tree, repo)
2538 2535
2539 def matchany(ui, specs, repo=None): 2536 def matchany(ui, specs, repo=None):
2540 """Create a matcher that will include any revisions matching one of the 2537 """Create a matcher that will include any revisions matching one of the
2541 given specs""" 2538 given specs"""
2542 if not specs: 2539 if not specs: