changeset 25255:ad1d2c952889

fileset: pretty print syntax tree in debug output
author Yuya Nishihara <yuya@tcha.org>
date Sun, 26 Apr 2015 22:26:44 +0900
parents 060bdfef2517
children 5a8398b085ed
files mercurial/commands.py mercurial/fileset.py tests/test-fileset.t
diffstat 3 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed May 06 10:17:41 2015 +0900
+++ b/mercurial/commands.py	Sun Apr 26 22:26:44 2015 +0900
@@ -2165,7 +2165,7 @@
     ctx = scmutil.revsingle(repo, opts.get('rev'), None)
     if ui.verbose:
         tree = fileset.parse(expr)
-        ui.note(tree, "\n")
+        ui.note(fileset.prettyformat(tree), "\n")
 
     for f in ctx.getfileset(expr):
         ui.write("%s\n" % f)
--- a/mercurial/fileset.py	Wed May 06 10:17:41 2015 +0900
+++ b/mercurial/fileset.py	Sun Apr 26 22:26:44 2015 +0900
@@ -517,5 +517,8 @@
 
     return getset(matchctx(ctx, subset, status), tree)
 
+def prettyformat(tree):
+    return parser.prettyformat(tree, ('string', 'symbol'))
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = symbols.values()
--- a/tests/test-fileset.t	Wed May 06 10:17:41 2015 +0900
+++ b/tests/test-fileset.t	Sun Apr 26 22:26:44 2015 +0900
@@ -16,15 +16,21 @@
 
 Test operators and basic patterns
 
-  $ fileset a1
+  $ fileset -v a1
+  ('symbol', 'a1')
   a1
-  $ fileset 'a*'
+  $ fileset -v 'a*'
+  ('symbol', 'a*')
   a1
   a2
-  $ fileset '"re:a\d"'
+  $ fileset -v '"re:a\d"'
+  ('string', 're:a\\d')
   a1
   a2
-  $ fileset 'a1 or a2'
+  $ fileset -v 'a1 or a2'
+  (or
+    ('symbol', 'a1')
+    ('symbol', 'a2'))
   a1
   a2
   $ fileset 'a1 | a2'