changeset 13098:f7d6750dcd01

util: make atomicfiles closable
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Tue, 07 Dec 2010 16:03:42 +0100
parents c922aacf6f1f
children a08b49d2f116
files mercurial/util.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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))