~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/atomicfile.py

[merge] aaron

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from warnings import warn
20
20
from osutils import rename
 
21
import errno
21
22
 
22
23
class AtomicFile(object):
23
24
    """A file that does an atomic-rename to move into place.
65
66
        self.f.close()
66
67
        self.f = None
67
68
        
 
69
        try:
 
70
            stat = os.lstat(self.realfilename)
 
71
            os.chmod(self.tmpfilename, stat.st_mode)
 
72
        except OSError, e:
 
73
            if e.errno != errno.ENOENT:
 
74
                raise
68
75
        rename(self.tmpfilename, self.realfilename)
69
76
 
70
77