Mercurial > public > mercurial-scm > hg
diff mercurial/commands.py @ 32584:746e12a767b3
cat: add formatter support
This is an example showing how formatter can handle the --output option.
git subrepo isn't supported for now.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 25 May 2017 21:53:44 +0900 |
parents | 1b90036f42f0 |
children | d3d262ff42c0 |
line wrap: on
line diff
--- a/mercurial/commands.py Sat May 27 17:58:36 2017 +0900 +++ b/mercurial/commands.py Thu May 25 21:53:44 2017 +0900 @@ -35,6 +35,7 @@ error, exchange, extensions, + formatter, graphmod, hbisect, help, @@ -1338,7 +1339,7 @@ _('print output to file with formatted name'), _('FORMAT')), ('r', 'rev', '', _('print the given revision'), _('REV')), ('', 'decode', None, _('apply any matching decode filter')), - ] + walkopts, + ] + walkopts + formatteropts, _('[OPTION]... FILE...'), inferrepo=True) def cat(ui, repo, file1, *pats, **opts): @@ -1368,9 +1369,13 @@ if cmdutil.isstdiofilename(fntemplate): fntemplate = '' - if not fntemplate: + if fntemplate: + fm = formatter.nullformatter(ui, 'cat') + else: ui.pager('cat') - return cmdutil.cat(ui, repo, ctx, m, fntemplate, '', **opts) + fm = ui.formatter('cat', opts) + with fm: + return cmdutil.cat(ui, repo, ctx, m, fm, fntemplate, '', **opts) @command('^clone', [('U', 'noupdate', None, _('the clone will include an empty working '