Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 20497:19b1c62cee1c
commands.debugrevspec: add an option to print the optimized expression tree
This will be used in an upcoming patch to test that the optimizer works.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Thu, 13 Feb 2014 13:52:45 -0800 |
parents | 78f4c2b7052f |
children | ce3f3082ec45 |
comparison
equal
deleted
inserted
replaced
20496:acbd19b9fbe1 | 20497:19b1c62cee1c |
---|---|
2546 ui.write(('deltas against p2 : ') | 2546 ui.write(('deltas against p2 : ') |
2547 + fmt % pcfmt(nump2, numdeltas)) | 2547 + fmt % pcfmt(nump2, numdeltas)) |
2548 ui.write(('deltas against other : ') + fmt % pcfmt(numother, | 2548 ui.write(('deltas against other : ') + fmt % pcfmt(numother, |
2549 numdeltas)) | 2549 numdeltas)) |
2550 | 2550 |
2551 @command('debugrevspec', [], ('REVSPEC')) | 2551 @command('debugrevspec', |
2552 def debugrevspec(ui, repo, expr): | 2552 [('', 'optimize', None, _('print parsed tree after optimizing'))], |
2553 ('REVSPEC')) | |
2554 def debugrevspec(ui, repo, expr, **opts): | |
2553 """parse and apply a revision specification | 2555 """parse and apply a revision specification |
2554 | 2556 |
2555 Use --verbose to print the parsed tree before and after aliases | 2557 Use --verbose to print the parsed tree before and after aliases |
2556 expansion. | 2558 expansion. |
2557 """ | 2559 """ |
2559 tree = revset.parse(expr)[0] | 2561 tree = revset.parse(expr)[0] |
2560 ui.note(revset.prettyformat(tree), "\n") | 2562 ui.note(revset.prettyformat(tree), "\n") |
2561 newtree = revset.findaliases(ui, tree) | 2563 newtree = revset.findaliases(ui, tree) |
2562 if newtree != tree: | 2564 if newtree != tree: |
2563 ui.note(revset.prettyformat(newtree), "\n") | 2565 ui.note(revset.prettyformat(newtree), "\n") |
2566 if opts["optimize"]: | |
2567 weight, optimizedtree = revset.optimize(newtree, True) | |
2568 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n") | |
2564 func = revset.match(ui, expr) | 2569 func = revset.match(ui, expr) |
2565 for c in func(repo, revset.baseset(range(len(repo)))): | 2570 for c in func(repo, revset.baseset(range(len(repo)))): |
2566 ui.write("%s\n" % c) | 2571 ui.write("%s\n" % c) |
2567 | 2572 |
2568 @command('debugsetparents', [], _('REV1 [REV2]')) | 2573 @command('debugsetparents', [], _('REV1 [REV2]')) |