##// END OF EJS Templates
debugfileset: backport --show-stage option from debugrevspec...
Yuya Nishihara -
r38837:1d1c1645 default
parent child Browse files
Show More
@@ -888,15 +888,39 b' def debugextensions(ui, repo, **opts):'
888 @command('debugfileset',
888 @command('debugfileset',
889 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV')),
889 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV')),
890 ('', 'all-files', False,
890 ('', 'all-files', False,
891 _('test files from all revisions and working directory'))],
891 _('test files from all revisions and working directory')),
892 _('[-r REV] [--all-files] FILESPEC'))
892 ('p', 'show-stage', [],
893 _('print parsed tree at the given stage'), _('NAME'))],
894 _('[-r REV] [--all-files] [OPTION]... FILESPEC'))
893 def debugfileset(ui, repo, expr, **opts):
895 def debugfileset(ui, repo, expr, **opts):
894 '''parse and apply a fileset specification'''
896 '''parse and apply a fileset specification'''
895 opts = pycompat.byteskwargs(opts)
897 opts = pycompat.byteskwargs(opts)
896 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
898 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
897 if ui.verbose:
899
898 tree = fileset.parse(expr)
900 stages = [
899 ui.note(fileset.prettyformat(tree), "\n")
901 ('parsed', pycompat.identity),
902 ]
903 stagenames = set(n for n, f in stages)
904
905 showalways = set()
906 if ui.verbose and not opts['show_stage']:
907 # show parsed tree by --verbose (deprecated)
908 showalways.add('parsed')
909 if opts['show_stage'] == ['all']:
910 showalways.update(stagenames)
911 else:
912 for n in opts['show_stage']:
913 if n not in stagenames:
914 raise error.Abort(_('invalid stage name: %s') % n)
915 showalways.update(opts['show_stage'])
916
917 tree = fileset.parse(expr)
918 for n, f in stages:
919 tree = f(tree)
920 if n in showalways:
921 if opts['show_stage'] or n != 'parsed':
922 ui.write(("* %s:\n") % n)
923 ui.write(fileset.prettyformat(tree), "\n")
900
924
901 files = set()
925 files = set()
902 if opts['all_files']:
926 if opts['all_files']:
@@ -274,7 +274,7 b' Show all commands + options'
274 debugdiscovery: old, nonheads, rev, ssh, remotecmd, insecure
274 debugdiscovery: old, nonheads, rev, ssh, remotecmd, insecure
275 debugdownload: output
275 debugdownload: output
276 debugextensions: template
276 debugextensions: template
277 debugfileset: rev, all-files
277 debugfileset: rev, all-files, show-stage
278 debugformat: template
278 debugformat: template
279 debugfsinfo:
279 debugfsinfo:
280 debuggetbundle: head, common, type
280 debuggetbundle: head, common, type
@@ -114,6 +114,44 b' Test invalid syntax'
114 hg: parse error: invalid pattern kind: foo
114 hg: parse error: invalid pattern kind: foo
115 [255]
115 [255]
116
116
117 Show parsed tree at stages:
118
119 $ fileset -p unknown a
120 abort: invalid stage name: unknown
121 [255]
122
123 $ fileset -p parsed 'path:a1 or glob:b?'
124 * parsed:
125 (or
126 (kindpat
127 (symbol 'path')
128 (symbol 'a1'))
129 (kindpat
130 (symbol 'glob')
131 (symbol 'b?')))
132 a1
133 b1
134 b2
135
136 $ fileset -p all 'a1 or a2 or (grep("b") & clean())'
137 * parsed:
138 (or
139 (or
140 (symbol 'a1')
141 (symbol 'a2'))
142 (group
143 (and
144 (func
145 (symbol 'grep')
146 (string 'b'))
147 (func
148 (symbol 'clean')
149 None))))
150 a1
151 a2
152 b1
153 b2
154
117 Test files status
155 Test files status
118
156
119 $ rm a1
157 $ rm a1
General Comments 0
You need to be logged in to leave comments. Login now