diff hgext/mq.py @ 37603:678d760c71ff

export: extract function to write patch to file object (API) This is common use case of cmdutil.export(), and we wouldn't want to handle formatter thingy everywhere. .. api:: The ``fp`` argument is removed from ``cmdutil.export()``. Use ``cmdutil.exportfile()`` instead.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 12 Apr 2018 22:59:49 +0900
parents c4a0626f6b6e
children 88c2d0e639b1
line wrap: on
line diff
--- a/hgext/mq.py	Thu Apr 12 22:39:43 2018 +0900
+++ b/hgext/mq.py	Thu Apr 12 22:59:49 2018 +0900
@@ -2182,9 +2182,8 @@
                     self.checkpatchname(patchname, force)
                     self.fullseries.insert(0, patchname)
 
-                    patchf = self.opener(patchname, "w")
-                    cmdutil.export(repo, [n], fp=patchf, opts=diffopts)
-                    patchf.close()
+                    with self.opener(patchname, "w") as fp:
+                        cmdutil.exportfile(repo, [n], fp, opts=diffopts)
 
                     se = statusentry(n, patchname)
                     self.applied.insert(0, se)