[Pkg-bazaar-commits] ./bzr/unstable r497: - new AtomicFile.close() aborts if appropriate
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:19:56 UTC 2009
------------------------------------------------------------
revno: 497
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Mon 2005-05-16 12:37:37 +1000
message:
- new AtomicFile.close() aborts if appropriate
- Doc
modified:
bzrlib/atomicfile.py
-------------- next part --------------
=== modified file 'bzrlib/atomicfile.py'
--- a/bzrlib/atomicfile.py 2005-05-10 08:56:28 +0000
+++ b/bzrlib/atomicfile.py 2005-05-16 02:37:37 +0000
@@ -46,6 +46,7 @@
self.closed = property(self.f.closed)
def commit(self):
+ """Close the file and move to final name."""
import sys, os
self.f.close()
@@ -54,8 +55,14 @@
os.rename(self.tmpfilename, self.realfilename)
def abort(self):
+ """Discard temporary file without committing changes."""
import os
self.f.close()
os.remove(self.tmpfilename)
+
+ def close(self):
+ """Discard the file unless already committed."""
+ if not self.closed:
+ self.abort()
More information about the Pkg-bazaar-commits
mailing list