Mercurial > public > mercurial-scm > hg
diff mercurial/commands.py @ 37604:daafaff4e5be
export: enable formatter support (API)
This change is basically the same as "hg cat". A formatter object is created
by caller.
.. api::
``cmdutil.export()`` takes a formatter as an argument.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 12 Apr 2018 23:13:55 +0900 |
parents | 7a9c905e51f9 |
children | fd1dd79cff20 |
line wrap: on
line diff
--- a/mercurial/commands.py Thu Apr 12 22:59:49 2018 +0900 +++ b/mercurial/commands.py Thu Apr 12 23:13:55 2018 +0900 @@ -1894,7 +1894,7 @@ _('print output to file with formatted name'), _('FORMAT')), ('', 'switch-parent', None, _('diff against the second parent')), ('r', 'rev', [], _('revisions to export'), _('REV')), - ] + diffopts, + ] + diffopts + formatteropts, _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'), cmdtype=readonly) def export(ui, repo, *changesets, **opts): """dump the header and diffs for one or more changesets @@ -1976,11 +1976,15 @@ if cmdutil.isstdiofilename(fntemplate): fntemplate = '' - if not fntemplate: + if fntemplate: + fm = formatter.nullformatter(ui, 'export', opts) + else: ui.pager('export') - cmdutil.export(repo, revs, fntemplate=fntemplate, - switch_parent=opts.get('switch_parent'), - opts=patch.diffallopts(ui, opts)) + fm = ui.formatter('export', opts) + with fm: + cmdutil.export(repo, revs, fm, fntemplate=fntemplate, + switch_parent=opts.get('switch_parent'), + opts=patch.diffallopts(ui, opts)) @command('files', [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),