changeset 8327:aa25be1c2889

atomictempfile: delegate to posixfile instead of inheriting from it
author Bryan O'Sullivan <bos@serpentine.com>
date Thu, 26 Mar 2009 13:12:11 -0700
parents b7017097a4ec
children 91f1fe78454c
files mercurial/util.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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"""