886 fm.end() |
886 fm.end() |
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 _('[-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']: |
903 for r in repo: |
927 for r in repo: |
904 c = repo[r] |
928 c = repo[r] |