[RFC] race-free-rename ?

Aaron Bentley aaron.bentley at utoronto.ca
Tue Oct 16 14:04:58 BST 2007


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

Martin Pool wrote:
> On 10/16/07, Robert Collins <robertc at robertcollins.net> wrote:
>> So, for packs, I'd like a rename() which is guaranteed race-free. That
>> is, it should fail if it cannot atomically rename the source to the
>> destination (e.g. if the destination already exists and the fs does not
>> support rename-over-the-top).

So IOW, it has the exact same behavior as the underlying OS's rename?

> it would be reasonable to add a
> method to do it.  I would suggest adding a new one, maybe
> rename_atomically_or_fail.  'race free rename' might imply various
> strange things depending on who reads it.

"race-free-rename" gave me exactly the wrong connotations.  It sounded
like it was an atomic rename built on top of a non-atomic rename-- i.e.
something that is technically impossible and can only be approximated.

rename_atomically_or_fail sounds like it would always fail on win32,
since renames aren't atomic on win32.

Perhaps just rename_or_fail?

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

iD8DBQFHFLb50F+nu1YWqI0RAgMgAJ4v25+op+fSnPGQPQEz+UEellBYRACdFTBq
cZReC5e9j5syMuCW18fII0Y=
=/4Ns
-----END PGP SIGNATURE-----



More information about the bazaar mailing list