Patchwork [1,of,4] debugrevspec: pass lookup function to visualize fallback mechanism

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 4, 2015, 3:10 p.m.
Message ID <d31439b19ed278f05b0c.1438701027@mimosa>
Download mbox | patch
Permalink /patch/10100/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 4, 2015, 3:10 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1437228138 -32400
#      Sat Jul 18 23:02:18 2015 +0900
# Node ID d31439b19ed278f05b0c1e113fc9b48bb1627f7e
# Parent  d6106df97eddf20cf1a4c06dd3f0e77f9316442d
debugrevspec: pass lookup function to visualize fallback mechanism

The next patch will move the exceptional parsing of old-style ranges
to revset.tokenize(). This patch will allow us to see the result tree.

Note that the parsing result of '-a-b-c-' is incorrect at this changeset.
It will be fixed soon.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2933,7 +2933,7 @@  def debugrevspec(ui, repo, expr, **opts)
     expansion.
     """
     if ui.verbose:
-        tree = revset.parse(expr)
+        tree = revset.parse(expr, lookup=repo.__contains__)
         ui.note(revset.prettyformat(tree), "\n")
         newtree = revset.findaliases(ui, tree)
         if newtree != tree:
@@ -2945,7 +2945,7 @@  def debugrevspec(ui, repo, expr, **opts)
         if opts["optimize"]:
             weight, optimizedtree = revset.optimize(newtree, True)
             ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
-    func = revset.match(ui, expr)
+    func = revset.match(ui, expr, repo)
     revs = func(repo)
     if ui.verbose:
         ui.note("* set:\n", revset.prettyformatset(revs), "\n")
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -197,10 +197,16 @@  names that should work without quoting
   <filteredset
     <baseset [7]>>
   7
-  $ try -- '-a-b-c-' # complains
-  hg: parse error at 7: not a prefix: end
-  [255]
-  $ log -a-b-c- # succeeds with fallback
+
+names that should be caught by fallback mechanism
+
+  $ try -- '-a-b-c-'
+  (negate
+    ('symbol', 'a-b-c-'))
+  * set:
+  <baseset [4]>
+  4
+  $ log -a-b-c-
   4
 
   $ try -- -a-b-c--a # complains