[PATCH 4 of 6] cat: stop using makefileobj()
Yuya Nishihara
yuya at tcha.org
Tue May 30 12:07:12 EDT 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1495716189 -32400
# Thu May 25 21:43:09 2017 +0900
# Node ID d403731c94f481cb5349580f374e8a8564fed2f4
# Parent aa8b8c29ea0f3345ee490275a42c279fbe1f6e39
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.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2636,8 +2636,12 @@ def cat(ui, repo, ctx, matcher, fntempla
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)
More information about the Mercurial-devel
mailing list