[MERGE] TreeTransform rolls back on exception (#67699)

Aaron Bentley aaron.bentley at utoronto.ca
Tue Aug 21 16:42:44 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

On *nix, it's highly unusual for TreeTransform to fail in the middle of
apply().  On Windows, due to the way open files are handled, this is far
more common.

This patch does not attempt to fix all the problems on Windows, just to
provide the basic guarantee that if TreeTransform fails, your local
changes are not lost.

This patch introduces a TreeTransform helper class called _FileMover.
Instead of deleting files immediately, _FileMover renames them and marks
them pending_deletion.  Actual deletions are performed after
_apply_insertions and _apply_removals have successfully completed.  At
this point, the tree is in a good state, so any failures on deletion
will not leave it in a bad state.

Pretty simple, eh?

So in place of one os.unlink call, there are now 2 calls:  os.rename and
os.unlink.  I tested "revert -r" 50, on bzr.dev, and the performance
impact was minimal.

without rollback:
real    0m3.195s
user    0m2.752s
sys     0m0.296s

with rollback:
real    0m3.215s
user    0m2.844s
sys     0m0.272s

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGywf00F+nu1YWqI0RAlzFAJ9HD6TBmsEgvBnIXr/zqZJkQb4ckgCfY5iq
b3ci4FcA37MC19yxFSqo7mQ=
=TNAu
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: transform-rollback.patch
Type: text/x-patch
Size: 18791 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070821/80711bb2/attachment.bin 


More information about the bazaar mailing list