Mercurial > hg
diff hgext/largefiles/localstore.py @ 27769:40bd01be5c25
largefiles: use a context manager in _getfile
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Tue, 12 Jan 2016 14:27:42 -0800 |
parents | c082a4756ed7 |
children | 207c0db08953 |
line wrap: on
line diff
--- a/hgext/largefiles/localstore.py Tue Jan 12 16:16:19 2016 -0800 +++ b/hgext/largefiles/localstore.py Tue Jan 12 14:27:42 2016 -0800 @@ -39,11 +39,8 @@ if not path: raise basestore.StoreError(filename, hash, self.url, _("can't get file locally")) - fd = open(path, 'rb') - try: + with open(path, 'rb') as fd: return lfutil.copyandhash(fd, tmpfile) - finally: - fd.close() def _verifyfile(self, cctx, cset, contents, standin, verified): filename = lfutil.splitstandin(standin)