# HG changeset patch # User Bryan O'Sullivan # Date 1452637662 28800 # Node ID 40bd01be5c25fe0f3b4f1a6e84303761b09d3f9b # Parent 5ef99738a56200badce6ad240449cf806b0c2d3e largefiles: use a context manager in _getfile diff -r 5ef99738a562 -r 40bd01be5c25 hgext/largefiles/localstore.py --- 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)