atomictempfile: delegate to posixfile instead of inheriting from it
authorBryan O'Sullivan <bos@serpentine.com>
Thu, 26 Mar 2009 13:12:11 -0700
changeset 8327 aa25be1c2889
parent 8326 b7017097a4ec
child 8328 91f1fe78454c
atomictempfile: delegate to posixfile instead of inheriting from it
mercurial/util.py
--- a/mercurial/util.py	Fri May 08 22:35:10 2009 +0200
+++ b/mercurial/util.py	Thu Mar 26 13:12:11 2009 -0700
@@ -964,7 +964,7 @@
         raise
     return temp
 
-class atomictempfile(posixfile):
+class atomictempfile:
     """file-like object that atomically updates a file
 
     All writes will be redirected to a temporary copy of the original
@@ -975,11 +975,14 @@
         self.__name = name
         self.temp = mktempcopy(name, emptyok=('w' in mode),
                                createmode=createmode)
-        posixfile.__init__(self, self.temp, mode)
+        self._fp = posixfile(self.temp, mode)
+
+    def __getattr__(self, name):
+        return getattr(self._fp, name)
 
     def rename(self):
         if not self.closed:
-            posixfile.close(self)
+            self._fp.close()
             rename(self.temp, localpath(self.__name))
 
     def __del__(self):
@@ -987,7 +990,7 @@
             try:
                 os.unlink(self.temp)
             except: pass
-            posixfile.close(self)
+            self._fp.close()
 
 def makedirs(name, mode=None):
     """recursive directory creation with parent mode inheritance"""