Mercurial > hg
diff mercurial/bundlerepo.py @ 27776:6fe2da48a6dd
bundlerepo: use context manager for file I/O in _writetempbundle
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Tue, 12 Jan 2016 14:48:27 -0800 |
parents | d4071cc73f46 |
children | 88609cfa3745 |
line wrap: on
line diff
--- a/mercurial/bundlerepo.py Tue Jan 12 14:47:21 2016 -0800 +++ b/mercurial/bundlerepo.py Tue Jan 12 14:48:27 2016 -0800 @@ -245,17 +245,14 @@ fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-", suffix=".hg10un") self.tempfile = temp - fptemp = os.fdopen(fdtemp, 'wb') - try: + with os.fdopen(fdtemp, 'wb') as fptemp: fptemp.write(header) while True: chunk = read(2**18) if not chunk: break fptemp.write(chunk) - finally: - fptemp.close() return self.vfs.open(self.tempfile, mode="rb") self._tempparent = None