# HG changeset patch # User Bryan O'Sullivan # Date 2009-03-26 20:12:11 # Node ID aa25be1c2889e1411c58b7f0ec8b31237dbc3f5b # Parent b7017097a4ec45af1779728dcac0d3ef1779d076 atomictempfile: delegate to posixfile instead of inheriting from it diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -964,7 +964,7 @@ def mktempcopy(name, emptyok=False, crea 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 @@ class atomictempfile(posixfile): 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 @@ class atomictempfile(posixfile): 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"""