diff -r 94e07bb8e5dd -r f53bc3e37655 mercurial/util.py --- a/mercurial/util.py Thu May 14 23:05:16 2009 +0200 +++ b/mercurial/util.py Thu May 14 14:12:32 2009 -0700 @@ -971,6 +971,7 @@ """ def __init__(self, name, mode, createmode): self.__name = name + self._fp = None self.temp = mktempcopy(name, emptyok=('w' in mode), createmode=createmode) self._fp = posixfile(self.temp, mode) @@ -988,7 +989,8 @@ try: os.unlink(self.temp) except: pass - self._fp.close() + if self._fp: + self._fp.close() def makedirs(name, mode=None): """recursive directory creation with parent mode inheritance"""