Patchwork [1,of,3] commands.debugrevspec: add an option to print the optimized expression tree

login
register
mail settings
Submitter Siddharth Agarwal
Date Feb. 13, 2014, 10:10 p.m.
Message ID <36f133144674e0f91b4c.1392329430@dev1738.prn1.facebook.com>
Download mbox | patch
Permalink /patch/3637/
State Accepted
Commit 19b1c62cee1c83371780fa4621b8ac30f079c227
Headers show

Comments

Siddharth Agarwal - Feb. 13, 2014, 10:10 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1392328365 28800
#      Thu Feb 13 13:52:45 2014 -0800
# Node ID 36f133144674e0f91b4c16d3ca49c01b3046f572
# Parent  80628d4069be724089ea487a300d62f4cbd8970d
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.
Siddharth Agarwal - Feb. 14, 2014, 6:55 p.m.
On 02/13/2014 02:10 PM, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1392328365 28800
> #      Thu Feb 13 13:52:45 2014 -0800
> # Node ID 36f133144674e0f91b4c16d3ca49c01b3046f572
> # Parent  80628d4069be724089ea487a300d62f4cbd8970d
> commands.debugrevspec: add an option to print the optimized expression tree

Looks like mpm landed these.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -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)
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -250,7 +250,7 @@ 
   debugrebuilddirstate: rev
   debugrename: rev
   debugrevlog: changelog, manifest, dump
-  debugrevspec: 
+  debugrevspec: optimize
   debugsetparents: 
   debugsub: rev
   debugsuccessorssets: