comparison mercurial/debugcommands.py @ 38802:f0a574dbfae9

debugfileset: add option to show matcher representation
author Yuya Nishihara <yuya@tcha.org>
date Sat, 21 Jul 2018 15:05:40 +0900
parents 1d1c1645d7b9
children b9162ea1b815
comparison
equal deleted inserted replaced
38801:1d1c1645d7b9 38802:f0a574dbfae9
887 887
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 ('s', 'show-matcher', None,
893 _('print internal representation of matcher')),
892 ('p', 'show-stage', [], 894 ('p', 'show-stage', [],
893 _('print parsed tree at the given stage'), _('NAME'))], 895 _('print parsed tree at the given stage'), _('NAME'))],
894 _('[-r REV] [--all-files] [OPTION]... FILESPEC')) 896 _('[-r REV] [--all-files] [OPTION]... FILESPEC'))
895 def debugfileset(ui, repo, expr, **opts): 897 def debugfileset(ui, repo, expr, **opts):
896 '''parse and apply a fileset specification''' 898 '''parse and apply a fileset specification'''
937 else: 939 else:
938 files.update(ctx.files()) 940 files.update(ctx.files())
939 files.update(ctx.substate) 941 files.update(ctx.substate)
940 942
941 m = ctx.matchfileset(expr) 943 m = ctx.matchfileset(expr)
944 if opts['show_matcher'] or (opts['show_matcher'] is None and ui.verbose):
945 ui.write(('* matcher:\n'), stringutil.prettyrepr(m), '\n')
942 for f in sorted(files): 946 for f in sorted(files):
943 if not m(f): 947 if not m(f):
944 continue 948 continue
945 ui.write("%s\n" % f) 949 ui.write("%s\n" % f)
946 950