util: make atomicfiles closable
authorDan Villiom Podlaski Christiansen <danchr@gmail.com>
Tue, 07 Dec 2010 16:03:42 +0100
changeset 13098 f7d6750dcd01
parent 13097 c922aacf6f1f
child 13099 a08b49d2f116
util: make atomicfiles closable
mercurial/util.py
--- a/mercurial/util.py	Mon Dec 06 21:17:27 2010 -0500
+++ b/mercurial/util.py	Tue Dec 07 16:03:42 2010 +0100
@@ -822,7 +822,7 @@
             self._fp.close()
             rename(self.temp, localpath(self.__name))
 
-    def __del__(self):
+    def close(self):
         if not self._fp:
             return
         if not self._fp.closed:
@@ -831,6 +831,9 @@
             except: pass
             self._fp.close()
 
+    def __del__(self):
+        self.close()
+
 def makedirs(name, mode=None):
     """recursive directory creation with parent mode inheritance"""
     parent = os.path.abspath(os.path.dirname(name))