comparison mercurial/revset.py @ 29955:1b5931604a5a

revset: add option to make matcher takes the ordering of the input set This allows us to evaluate match(subset) as if 'subset & expr', which will be the complete fix for the issue5100.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 03 May 2016 14:18:28 +0900
parents 285a8c3e53f2
children 49d5434d68fb
comparison
equal deleted inserted replaced
29954:769aee32fae0 29955:1b5931604a5a
2692 2692
2693 def posttreebuilthook(tree, repo): 2693 def posttreebuilthook(tree, repo):
2694 # hook for extensions to execute code on the optimized tree 2694 # hook for extensions to execute code on the optimized tree
2695 pass 2695 pass
2696 2696
2697 def match(ui, spec, repo=None): 2697 def match(ui, spec, repo=None, order=defineorder):
2698 """Create a matcher for a single revision spec.""" 2698 """Create a matcher for a single revision spec
2699 return matchany(ui, [spec], repo=repo) 2699
2700 2700 If order=followorder, a matcher takes the ordering specified by the input
2701 def matchany(ui, specs, repo=None): 2701 set.
2702 """
2703 return matchany(ui, [spec], repo=repo, order=order)
2704
2705 def matchany(ui, specs, repo=None, order=defineorder):
2702 """Create a matcher that will include any revisions matching one of the 2706 """Create a matcher that will include any revisions matching one of the
2703 given specs""" 2707 given specs
2708
2709 If order=followorder, a matcher takes the ordering specified by the input
2710 set.
2711 """
2704 if not specs: 2712 if not specs:
2705 def mfunc(repo, subset=None): 2713 def mfunc(repo, subset=None):
2706 return baseset() 2714 return baseset()
2707 return mfunc 2715 return mfunc
2708 if not all(specs): 2716 if not all(specs):
2716 tree = ('or', ('list',) + tuple(parse(s, lookup) for s in specs)) 2724 tree = ('or', ('list',) + tuple(parse(s, lookup) for s in specs))
2717 2725
2718 if ui: 2726 if ui:
2719 tree = expandaliases(ui, tree) 2727 tree = expandaliases(ui, tree)
2720 tree = foldconcat(tree) 2728 tree = foldconcat(tree)
2721 tree = analyze(tree) 2729 tree = analyze(tree, order)
2722 tree = optimize(tree) 2730 tree = optimize(tree)
2723 posttreebuilthook(tree, repo) 2731 posttreebuilthook(tree, repo)
2724 return makematcher(tree) 2732 return makematcher(tree)
2725 2733
2726 def makematcher(tree): 2734 def makematcher(tree):