[PATCH 5 of 5] fileset: pretty print syntax tree in debug output
Yuya Nishihara
yuya at tcha.org
Fri May 22 09:11:48 CDT 2015
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1430054804 -32400
# Sun Apr 26 22:26:44 2015 +0900
# Node ID b20af4c65c86115ada63ebc011d985c514aaba80
# Parent e8998439901c3ed2ffe9cf22022f1f1f0d984be9
fileset: pretty print syntax tree in debug output
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2165,7 +2165,7 @@ def debugfileset(ui, repo, expr, **opts)
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)
diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -517,5 +517,8 @@ def getfileset(ctx, expr):
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()
diff --git a/tests/test-fileset.t b/tests/test-fileset.t
--- a/tests/test-fileset.t
+++ b/tests/test-fileset.t
@@ -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'
More information about the Mercurial-devel
mailing list