[Pkg-bazaar-commits] ./bzr/unstable r14: write inventory to temporary file and atomically replace
mbp at sourcefrog.net
mbp at sourcefrog.net
Fri Apr 10 07:24:54 UTC 2009
------------------------------------------------------------
revno: 14
committer: mbp at sourcefrog.net
timestamp: Wed 2005-03-09 18:14:22 +1100
message:
write inventory to temporary file and atomically replace
modified:
bzrlib/branch.py
-------------- next part --------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2005-03-09 07:00:48 +0000
+++ b/bzrlib/branch.py 2005-03-09 07:14:22 +0000
@@ -159,8 +159,13 @@
That is to say, the inventory describing changes underway, that
will be committed to the next revision.
"""
- inv.write_xml(self.controlfile('inventory', 'w'))
- mutter('wrote inventory to %s' % quotefn(self.controlfilename('inventory')))
+ ## TODO: factor out to atomicfile? is rename safe on windows?
+ tmpfname = self.controlfilename('inventory.tmp')
+ tmpf = file(tmpfname, 'w')
+ inv.write_xml(tmpf)
+ tmpf.close()
+ os.rename(tmpfname, self.controlfilename('inventory'))
+ mutter('wrote working inventory')
inventory = property(read_working_inventory, _write_inventory, None,
More information about the Pkg-bazaar-commits
mailing list