##// END OF EJS Templates
ui: use a context manager to handle file streams in edit()...
Matt Harbison -
r44328:e5f69e3b default
parent child Browse files
Show More
@@ -1766,9 +1766,8 b' class ui(object):'
1766 1766 prefix=b'hg-' + extra[b'prefix'] + b'-', suffix=suffix, dir=rdir
1767 1767 )
1768 1768 try:
1769 f = os.fdopen(fd, 'wb')
1770 f.write(util.tonativeeol(text))
1771 f.close()
1769 with os.fdopen(fd, 'wb') as f:
1770 f.write(util.tonativeeol(text))
1772 1771
1773 1772 environ = {b'HGUSER': user}
1774 1773 if b'transplant_source' in extra:
@@ -1794,9 +1793,8 b' class ui(object):'
1794 1793 blockedtag=b'editor',
1795 1794 )
1796 1795
1797 f = open(name, 'rb')
1798 t = util.fromnativeeol(f.read())
1799 f.close()
1796 with open(name, 'rb') as f:
1797 t = util.fromnativeeol(f.read())
1800 1798 finally:
1801 1799 os.unlink(name)
1802 1800
General Comments 0
You need to be logged in to leave comments. Login now