Patchwork [3,of,4] debugrevspec: add option to skip optimize() and evaluate unoptimized tree

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 12, 2016, 1:36 p.m.
Message ID <87e3a09996cb56331521.1473687398@mimosa>
Download mbox | patch
Permalink /patch/16593/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 12, 2016, 1:36 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1471750802 -32400
#      Sun Aug 21 12:40:02 2016 +0900
# Node ID 87e3a09996cb563315210364c1b9b47f04042726
# Parent  3212fdc92ea2f9754fc0ad79e1fd19e3968c9e1d
debugrevspec: add option to skip optimize() and evaluate unoptimized tree

This will help debugging optimizer bugs.

Maybe '--no-optimized' can be changed to '--optimized' (default: True) when
flags series landed.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3515,6 +3515,7 @@  def debugrevlog(ui, repo, file_=None, **
       _('print parsed tree after optimizing (DEPRECATED)')),
      ('p', 'show-stage', [],
       _('print parsed tree at the given stage'), _('NAME')),
+     ('', 'no-optimized', False, _('evaluate tree without optimization')),
      ],
     ('REVSPEC'))
 def debugrevspec(ui, repo, expr, **opts):
@@ -3530,6 +3531,8 @@  def debugrevspec(ui, repo, expr, **opts)
         ('analyzed', revset.analyze),
         ('optimized', revset.optimize),
     ]
+    if opts['no_optimized']:
+        stages = stages[:-1]
     stagenames = set(n for n, f in stages)
 
     showalways = set()
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -269,7 +269,7 @@  Show all commands + options
   debugrebuildfncache: 
   debugrename: rev
   debugrevlog: changelog, manifest, dir, dump
-  debugrevspec: optimize, show-stage
+  debugrevspec: optimize, show-stage, no-optimized
   debugsetparents: 
   debugsub: rev
   debugsuccessorssets: 
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -508,6 +508,21 @@  parsed tree at stages:
   hg: parse error: missing argument
   [255]
 
+  $ hg debugrevspec --no-optimized -p all '()'
+  * parsed:
+  (group
+    None)
+  * expanded:
+  (group
+    None)
+  * concatenated:
+  (group
+    None)
+  * analyzed:
+  None
+  hg: parse error: missing argument
+  [255]
+
   $ hg debugrevspec -p parsed -p analyzed -p optimized '(0|1)-1'
   * parsed:
   (minus
@@ -2058,6 +2073,32 @@  test optimization of trivial `or` operat
   5
   6
 
+unoptimized `or` looks like this
+
+  $ try --no-optimized -p analyzed '0|1|2|3|4'
+  * analyzed:
+  (or
+    ('symbol', '0')
+    ('symbol', '1')
+    ('symbol', '2')
+    ('symbol', '3')
+    ('symbol', '4'))
+  * set:
+  <addset
+    <addset
+      <baseset [0]>,
+      <baseset [1]>>,
+    <addset
+      <baseset [2]>,
+      <addset
+        <baseset [3]>,
+        <baseset [4]>>>>
+  0
+  1
+  2
+  3
+  4
+
 test that `_list` should be narrowed by provided `subset`
 
   $ log '0:2 and (null|1|2|3)'