hgext/largefiles/basestore.py
changeset 30142 3dcaf1c4e90d
parent 29307 67999697221a
child 31658 f1cf6a745264
--- a/hgext/largefiles/basestore.py	Sat Oct 08 00:59:40 2016 +0200
+++ b/hgext/largefiles/basestore.py	Sat Oct 08 00:59:41 2016 +0200
@@ -91,15 +91,13 @@
         storefilename = lfutil.storepath(self.repo, hash)
 
         tmpname = storefilename + '.tmp'
-        tmpfile = util.atomictempfile(tmpname,
-                                      createmode=self.repo.store.createmode)
-
-        try:
-            gothash = self._getfile(tmpfile, filename, hash)
-        except StoreError as err:
-            self.ui.warn(err.longmessage())
-            gothash = ""
-        tmpfile.close()
+        with util.atomictempfile(tmpname,
+                createmode=self.repo.store.createmode) as tmpfile:
+            try:
+                gothash = self._getfile(tmpfile, filename, hash)
+            except StoreError as err:
+                self.ui.warn(err.longmessage())
+                gothash = ""
 
         if gothash != hash:
             if gothash != "":