# HG changeset patch # User Matt Harbison # Date 2015-03-08 20:50:57 # Node ID e1cb460a35245edfa3d3b216352923ffe1be8566 # Parent 9640820bc957301b49bb677a4aee181de8d8266b files: split reusable implementation into cmdutil for subrepo support diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2219,6 +2219,24 @@ def forget(ui, repo, match, prefix, expl forgot.extend(f for f in forget if f not in rejected) return bad, forgot +def files(ui, ctx, m, fm, fmt): + rev = ctx.rev() + ret = 1 + ds = ctx._repo.dirstate + + for f in ctx.matches(m): + if rev is None and ds[f] == 'r': + continue + fm.startitem() + if ui.verbose: + fc = ctx[f] + fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags()) + fm.data(abspath=f) + fm.write('path', fmt, m.rel(f)) + ret = 0 + + return ret + def remove(ui, repo, m, prefix, after, force, subrepos): join = lambda f: os.path.join(prefix, f) ret = 0 diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3258,8 +3258,6 @@ def files(ui, repo, *pats, **opts): """ ctx = scmutil.revsingle(repo, opts.get('rev'), None) - rev = ctx.rev() - ret = 1 end = '\n' if opts.get('print0'): @@ -3268,17 +3266,7 @@ def files(ui, repo, *pats, **opts): fmt = '%s' + end m = scmutil.match(ctx, pats, opts) - ds = ctx._repo.dirstate - for f in ctx.matches(m): - if rev is None and ds[f] == 'r': - continue - fm.startitem() - if ui.verbose: - fc = ctx[f] - fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags()) - fm.data(abspath=f) - fm.write('path', fmt, m.rel(f)) - ret = 0 + ret = cmdutil.files(ui, ctx, m, fm, fmt) fm.end()