largefiles: use a context manager in _getfile
authorBryan O'Sullivan <bryano@fb.com>
Tue, 12 Jan 2016 14:27:42 -0800
changeset 27769 40bd01be5c25
parent 27768 5ef99738a562
child 27770 1b8c7d59be43
largefiles: use a context manager in _getfile
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)