diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -889,6 +889,8 @@ def debugextensions(ui, repo, **opts): [('r', 'rev', '', _('apply the filespec on this revision'), _('REV')), ('', 'all-files', False, _('test files from all revisions and working directory')), + ('s', 'show-matcher', None, + _('print internal representation of matcher')), ('p', 'show-stage', [], _('print parsed tree at the given stage'), _('NAME'))], _('[-r REV] [--all-files] [OPTION]... FILESPEC')) @@ -939,6 +941,8 @@ def debugfileset(ui, repo, expr, **opts) files.update(ctx.substate) m = ctx.matchfileset(expr) + if opts['show_matcher'] or (opts['show_matcher'] is None and ui.verbose): + ui.write(('* matcher:\n'), stringutil.prettyrepr(m), '\n') for f in sorted(files): if not m(f): continue diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -274,7 +274,7 @@ Show all commands + options debugdiscovery: old, nonheads, rev, ssh, remotecmd, insecure debugdownload: output debugextensions: template - debugfileset: rev, all-files, show-stage + debugfileset: rev, all-files, show-matcher, show-stage debugformat: template debugfsinfo: debuggetbundle: head, common, type diff --git a/tests/test-fileset.t b/tests/test-fileset.t --- a/tests/test-fileset.t +++ b/tests/test-fileset.t @@ -18,13 +18,19 @@ Test operators and basic patterns $ fileset -v a1 (symbol 'a1') + * matcher: + a1 $ fileset -v 'a*' (symbol 'a*') + * matcher: + a1 a2 $ fileset -v '"re:a\d"' (string 're:a\\d') + * matcher: + a1 a2 $ fileset -v '!re:"a\d"' @@ -32,6 +38,10 @@ Test operators and basic patterns (kindpat (symbol 're') (string 'a\\d'))) + * matcher: + >> b1 b2 $ fileset -v 'path:a1 or glob:b?' @@ -42,10 +52,14 @@ Test operators and basic patterns (kindpat (symbol 'glob') (symbol 'b?'))) + * matcher: + , + ]> a1 b1 b2 - $ fileset -v 'a1 or a2' + $ fileset -v --no-show-matcher 'a1 or a2' (or (symbol 'a1') (symbol 'a2')) @@ -133,7 +147,7 @@ Show parsed tree at stages: b1 b2 - $ fileset -p all 'a1 or a2 or (grep("b") & clean())' + $ fileset -p all -s 'a1 or a2 or (grep("b") & clean())' * parsed: (or (or @@ -147,6 +161,14 @@ Show parsed tree at stages: (func (symbol 'clean') None)))) + * matcher: + , + ]>, + , + m2=>]> a1 a2 b1