changeset 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 acbd19b9fbe1
children fb2df4506c87
files mercurial/commands.py tests/test-completion.t
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Feb 12 16:09:18 2014 +0100
+++ b/mercurial/commands.py	Thu Feb 13 13:52:45 2014 -0800
@@ -2548,8 +2548,10 @@
             ui.write(('deltas against other : ') + fmt % pcfmt(numother,
                                                              numdeltas))
 
-@command('debugrevspec', [], ('REVSPEC'))
-def debugrevspec(ui, repo, expr):
+@command('debugrevspec',
+    [('', 'optimize', None, _('print parsed tree after optimizing'))],
+    ('REVSPEC'))
+def debugrevspec(ui, repo, expr, **opts):
     """parse and apply a revision specification
 
     Use --verbose to print the parsed tree before and after aliases
@@ -2561,6 +2563,9 @@
         newtree = revset.findaliases(ui, tree)
         if newtree != tree:
             ui.note(revset.prettyformat(newtree), "\n")
+        if opts["optimize"]:
+            weight, optimizedtree = revset.optimize(newtree, True)
+            ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
     func = revset.match(ui, expr)
     for c in func(repo, revset.baseset(range(len(repo)))):
         ui.write("%s\n" % c)
--- a/tests/test-completion.t	Wed Feb 12 16:09:18 2014 +0100
+++ b/tests/test-completion.t	Thu Feb 13 13:52:45 2014 -0800
@@ -250,7 +250,7 @@
   debugrebuilddirstate: rev
   debugrename: rev
   debugrevlog: changelog, manifest, dump
-  debugrevspec: 
+  debugrevspec: optimize
   debugsetparents: 
   debugsub: rev
   debugsuccessorssets: