cat: stop using makefileobj()
authorYuya Nishihara <yuya@tcha.org>
Thu, 25 May 2017 21:43:09 +0900
changeset 32608 7f4435078a8f
parent 32607 e9bf3e132ea9
child 32609 7bfa1b199972
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.
mercurial/cmdutil.py
--- 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)