mercurial/commands.py
changeset 37604 daafaff4e5be
parent 37598 7a9c905e51f9
child 37620 fd1dd79cff20
--- 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')),