Show More
@@ -3530,6 +3530,7 b' def debugrevspec(ui, repo, expr, **opts)' | |||||
3530 | if newtree != tree: |
|
3530 | if newtree != tree: | |
3531 | ui.note(("* concatenated:\n"), revset.prettyformat(newtree), "\n") |
|
3531 | ui.note(("* concatenated:\n"), revset.prettyformat(newtree), "\n") | |
3532 | if opts["optimize"]: |
|
3532 | if opts["optimize"]: | |
|
3533 | newtree = revset.analyze(newtree) | |||
3533 | optimizedtree = revset.optimize(newtree) |
|
3534 | optimizedtree = revset.optimize(newtree) | |
3534 | ui.note(("* optimized:\n"), |
|
3535 | ui.note(("* optimized:\n"), | |
3535 | revset.prettyformat(optimizedtree), "\n") |
|
3536 | revset.prettyformat(optimizedtree), "\n") |
@@ -2343,12 +2343,6 b' def _fixops(x):' | |||||
2343 | return (op,) + tuple(_fixops(y) for y in x[1:]) |
|
2343 | return (op,) + tuple(_fixops(y) for y in x[1:]) | |
2344 |
|
2344 | |||
2345 | def _analyze(x): |
|
2345 | def _analyze(x): | |
2346 | """Transform raw parsed tree to evaluatable tree which can be fed to |
|
|||
2347 | optimize() or getset() |
|
|||
2348 |
|
||||
2349 | All pseudo operations should be mapped to real operations or functions |
|
|||
2350 | defined in methods or symbols table respectively. |
|
|||
2351 | """ |
|
|||
2352 | if x is None: |
|
2346 | if x is None: | |
2353 | return x |
|
2347 | return x | |
2354 |
|
2348 | |||
@@ -2399,11 +2393,16 b' def _analyze(x):' | |||||
2399 | return (op, x[1], _analyze(x[2])) |
|
2393 | return (op, x[1], _analyze(x[2])) | |
2400 | raise ValueError('invalid operator %r' % op) |
|
2394 | raise ValueError('invalid operator %r' % op) | |
2401 |
|
2395 | |||
|
2396 | def analyze(x): | |||
|
2397 | """Transform raw parsed tree to evaluatable tree which can be fed to | |||
|
2398 | optimize() or getset() | |||
|
2399 | ||||
|
2400 | All pseudo operations should be mapped to real operations or functions | |||
|
2401 | defined in methods or symbols table respectively. | |||
|
2402 | """ | |||
|
2403 | return _analyze(x) | |||
|
2404 | ||||
2402 | def _optimize(x, small): |
|
2405 | def _optimize(x, small): | |
2403 | """Optimize evaluatable tree |
|
|||
2404 |
|
||||
2405 | All pseudo operations should be transformed beforehand. |
|
|||
2406 | """ |
|
|||
2407 | if x is None: |
|
2406 | if x is None: | |
2408 | return 0, x |
|
2407 | return 0, x | |
2409 |
|
2408 | |||
@@ -2505,7 +2504,10 b' def _optimize(x, small):' | |||||
2505 | raise ValueError('invalid operator %r' % op) |
|
2504 | raise ValueError('invalid operator %r' % op) | |
2506 |
|
2505 | |||
2507 | def optimize(tree): |
|
2506 | def optimize(tree): | |
2508 | tree = _analyze(tree) |
|
2507 | """Optimize evaluatable tree | |
|
2508 | ||||
|
2509 | All pseudo operations should be transformed beforehand. | |||
|
2510 | """ | |||
2509 | _weight, newtree = _optimize(tree, small=True) |
|
2511 | _weight, newtree = _optimize(tree, small=True) | |
2510 | return newtree |
|
2512 | return newtree | |
2511 |
|
2513 | |||
@@ -2619,6 +2621,7 b' def _makematcher(ui, tree, repo):' | |||||
2619 | if ui: |
|
2621 | if ui: | |
2620 | tree = expandaliases(ui, tree, showwarning=ui.warn) |
|
2622 | tree = expandaliases(ui, tree, showwarning=ui.warn) | |
2621 | tree = foldconcat(tree) |
|
2623 | tree = foldconcat(tree) | |
|
2624 | tree = analyze(tree) | |||
2622 | tree = optimize(tree) |
|
2625 | tree = optimize(tree) | |
2623 | posttreebuilthook(tree, repo) |
|
2626 | posttreebuilthook(tree, repo) | |
2624 | def mfunc(repo, subset=None): |
|
2627 | def mfunc(repo, subset=None): |
@@ -54,7 +54,7 b" these predicates use '\\0' as a separator" | |||||
54 | > tree = revset.parse(expr, lookup=repo.__contains__) |
|
54 | > tree = revset.parse(expr, lookup=repo.__contains__) | |
55 | > ui.note(revset.prettyformat(tree), "\n") |
|
55 | > ui.note(revset.prettyformat(tree), "\n") | |
56 | > if opts["optimize"]: |
|
56 | > if opts["optimize"]: | |
57 | > opttree = revset.optimize(tree) |
|
57 | > opttree = revset.optimize(revset.analyze(tree)) | |
58 | > ui.note("* optimized:\n", revset.prettyformat(opttree), "\n") |
|
58 | > ui.note("* optimized:\n", revset.prettyformat(opttree), "\n") | |
59 | > func = revset.match(ui, expr, repo) |
|
59 | > func = revset.match(ui, expr, repo) | |
60 | > revs = func(repo) |
|
60 | > revs = func(repo) |
General Comments 0
You need to be logged in to leave comments.
Login now