comparison 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
comparison
equal deleted inserted replaced
37603:678d760c71ff 37604:daafaff4e5be
1892 @command('^export', 1892 @command('^export',
1893 [('o', 'output', '', 1893 [('o', 'output', '',
1894 _('print output to file with formatted name'), _('FORMAT')), 1894 _('print output to file with formatted name'), _('FORMAT')),
1895 ('', 'switch-parent', None, _('diff against the second parent')), 1895 ('', 'switch-parent', None, _('diff against the second parent')),
1896 ('r', 'rev', [], _('revisions to export'), _('REV')), 1896 ('r', 'rev', [], _('revisions to export'), _('REV')),
1897 ] + diffopts, 1897 ] + diffopts + formatteropts,
1898 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'), cmdtype=readonly) 1898 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'), cmdtype=readonly)
1899 def export(ui, repo, *changesets, **opts): 1899 def export(ui, repo, *changesets, **opts):
1900 """dump the header and diffs for one or more changesets 1900 """dump the header and diffs for one or more changesets
1901 1901
1902 Print the changeset header and diffs for one or more revisions. 1902 Print the changeset header and diffs for one or more revisions.
1974 1974
1975 fntemplate = opts.get('output') 1975 fntemplate = opts.get('output')
1976 if cmdutil.isstdiofilename(fntemplate): 1976 if cmdutil.isstdiofilename(fntemplate):
1977 fntemplate = '' 1977 fntemplate = ''
1978 1978
1979 if not fntemplate: 1979 if fntemplate:
1980 fm = formatter.nullformatter(ui, 'export', opts)
1981 else:
1980 ui.pager('export') 1982 ui.pager('export')
1981 cmdutil.export(repo, revs, fntemplate=fntemplate, 1983 fm = ui.formatter('export', opts)
1982 switch_parent=opts.get('switch_parent'), 1984 with fm:
1983 opts=patch.diffallopts(ui, opts)) 1985 cmdutil.export(repo, revs, fm, fntemplate=fntemplate,
1986 switch_parent=opts.get('switch_parent'),
1987 opts=patch.diffallopts(ui, opts))
1984 1988
1985 @command('files', 1989 @command('files',
1986 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')), 1990 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
1987 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), 1991 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
1988 ] + walkopts + formatteropts + subrepoopts, 1992 ] + walkopts + formatteropts + subrepoopts,