[MERGE] Rename on Windows is able to change filename case. (#77740)

Alexander Belchenko bialix at ukr.net
Mon Nov 12 20:52:00 GMT 2007


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

Aaron Bentley пишет:
> Alexander Belchenko wrote:
>> I'm also like to see the complete fix, but we need some way
>> to detect case-insensitivity first.
> 
> I'm not sure that's true.  We could handle it this way:
> 
> rename target -> tmp (success)
> rename src -> target (failure)
> rename tmp -> target (success)
> 
> We would be subject to race conditions, but fancy_rename already is.

What about this variant for fancy_rename:

=== modified file 'bzrlib/osutils.py'
- --- bzrlib/osutils.py   2007-11-04 11:45:30 +0000
+++ bzrlib/osutils.py   2007-11-12 20:45:18 +0000
@@ -234,10 +234,16 @@

     success = False
     try:
- -        # This may throw an exception, in which case success will
- -        # not be set.
- -        rename_func(old, new)
- -        success = True
+        try:
+            # This may throw an exception, in which case success will
+            # not be set.
+            rename_func(old, new)
+            success = True
+        except (IOError, OSError), e:
+            # case insensitive filesystem may be?
+            if (not file_existed
+                or e.errno not in (None, errno.ENOENT, errno.ENOTDIR)):
+                raise
     finally:
         if file_existed:
             # If the file used to exist, rename it back into place


It works on win32 for changing case.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHOLzwzYr338mxwCURAgLeAJ9Z/B7uexQy4xmS4TSUon+cKtxt8ACfTuxN
aesf+8zRm4psyAjnjWivTMY=
=Ii0R
-----END PGP SIGNATURE-----



More information about the bazaar mailing list