##// END OF EJS Templates
cat: use with statement to close output file
Yuya Nishihara -
r32577:7bfa1b19 default
parent child Browse files
Show More
@@ -2642,11 +2642,11 b' def cat(ui, repo, ctx, matcher, fntempla'
2642 fp = open(filename, 'wb')
2642 fp = open(filename, 'wb')
2643 else:
2643 else:
2644 fp = _unclosablefile(ui.fout)
2644 fp = _unclosablefile(ui.fout)
2645 data = ctx[path].data()
2645 with fp:
2646 if opts.get('decode'):
2646 data = ctx[path].data()
2647 data = repo.wwritedata(path, data)
2647 if opts.get('decode'):
2648 fp.write(data)
2648 data = repo.wwritedata(path, data)
2649 fp.close()
2649 fp.write(data)
2650
2650
2651 # Automation often uses hg cat on single files, so special case it
2651 # Automation often uses hg cat on single files, so special case it
2652 # for performance to avoid the cost of parsing the manifest.
2652 # for performance to avoid the cost of parsing the manifest.
General Comments 0
You need to be logged in to leave comments. Login now