changeset 32582:7f4435078a8f

cat: stop using makefileobj() Prepares for porting to the formatter API. We won't be able to utilize the abstraction provided by makefilename() because formatter must be instantiated per file.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 25 May 2017 21:43:09 +0900
parents e9bf3e132ea9
children 7bfa1b199972
files mercurial/cmdutil.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sat May 27 17:44:26 2017 +0900
+++ b/mercurial/cmdutil.py	Thu May 25 21:43:09 2017 +0900
@@ -2636,8 +2636,12 @@
     err = 1
 
     def write(path):
-        fp = makefileobj(repo, fntemplate, ctx.node(),
-                         pathname=os.path.join(prefix, path))
+        if fntemplate:
+            filename = makefilename(repo, fntemplate, ctx.node(),
+                                    pathname=os.path.join(prefix, path))
+            fp = open(filename, 'wb')
+        else:
+            fp = _unclosablefile(ui.fout)
         data = ctx[path].data()
         if opts.get('decode'):
             data = repo.wwritedata(path, data)