Mercurial > hg
diff mercurial/debugcommands.py @ 38610:3d8ef60569d8
fileset: make debugfileset filter repository files
This prepares for the structural change of the fileset. A computed fileset
will no longer be a set of files, but a boolean function (i.e. matcher) to
test if an input file matches the given fileset expression.
--all-files option is added because some examples in the test need to scan
files across revisions.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 09 Jun 2018 18:58:16 +0900 |
parents | f9805627af1f |
children | 760cc5dc01e8 |
line wrap: on
line diff
--- a/mercurial/debugcommands.py Sun Jul 08 19:24:18 2018 +0900 +++ b/mercurial/debugcommands.py Sat Jun 09 18:58:16 2018 +0900 @@ -875,16 +875,38 @@ fm.end() @command('debugfileset', - [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))], - _('[-r REV] FILESPEC')) + [('r', 'rev', '', _('apply the filespec on this revision'), _('REV')), + ('', 'all-files', False, + _('test files from all revisions and working directory'))], + _('[-r REV] [--all-files] FILESPEC')) def debugfileset(ui, repo, expr, **opts): '''parse and apply a fileset specification''' - ctx = scmutil.revsingle(repo, opts.get(r'rev'), None) + opts = pycompat.byteskwargs(opts) + ctx = scmutil.revsingle(repo, opts.get('rev'), None) if ui.verbose: tree = fileset.parse(expr) ui.note(fileset.prettyformat(tree), "\n") - for f in sorted(ctx.getfileset(expr)): + files = set() + if opts['all_files']: + for r in repo: + c = repo[r] + files.update(c.files()) + files.update(c.substate) + if opts['all_files'] or ctx.rev() is None: + wctx = repo[None] + files.update(repo.dirstate.walk(scmutil.matchall(repo), + subrepos=list(wctx.substate), + unknown=True, ignored=True)) + files.update(wctx.substate) + else: + files.update(ctx.files()) + files.update(ctx.substate) + + m = scmutil.matchfiles(repo, ctx.getfileset(expr)) + for f in sorted(files): + if not m(f): + continue ui.write("%s\n" % f) @command('debugformat',