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

Aaron Bentley aaron.bentley at utoronto.ca
Tue Nov 13 14:26:15 GMT 2007


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

Alexander Belchenko wrote:

bb:comment

> Still don't know. Maybe anybody else could shed light on this?

Well, it typically happens when you treat a file as a directory.  e.g.

$ python
Python 2.4.4 (#2, Apr  5 2007, 20:11:18)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.rmdir('subject_report.html')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OSError: [Errno 20] Not a directory: 'subject_report.html'

I don't think it's relevant to the case where a file may have been moved
out of the way.  So I think we should only catch ENOENT unless we hear
otherwise.

=== modified file 'bzrlib/osutils.py'
- --- bzrlib/osutils.py	2007-11-04 11:45:30 +0000
+++ bzrlib/osutils.py	2007-11-12 21:35:15 +0000
@@ -234,10 +234,17 @@

     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?

^^^ it's rare to see "may be" (meaning "perhaps") spelled as two words.
 It's idiomatic to use "maybe".  But while we're here, let's give a
clearer comment:

# source and target may be aliases of each other (e.g. on a
# case-insensitive filesystem), so we may have accidentally renamed
# source by when we tried to rename target

Note that case-insensitivity isn't the only way you can get aliasing.  I
think the Mac's implicit unicode normalization would have the same impact.


=== modified file 'bzrlib/workingtree.py'
- --- bzrlib/workingtree.py	2007-11-03 09:39:11 +0000
+++ bzrlib/workingtree.py	2007-11-10 13:16:12 +0000
@@ -1318,6 +1318,10 @@
                 only_change_inv = True
             elif self.has_filename(from_rel) and not
self.has_filename(to_rel):
                 only_change_inv = False
+            elif (sys.platform == 'win32'
+                and from_rel.lower() == to_rel.lower()
+                and self.has_filename(from_rel)):
+                only_change_inv = False

^^^ I don't think this is still needed.

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

iD8DBQFHObQH0F+nu1YWqI0RAnStAJ9Pa81Qo2AtFHDONYWTTl3MkiPFwACfcH4V
2Nogbv2EDsoBkTZtZ7UAm78=
=vk4y
-----END PGP SIGNATURE-----



More information about the bazaar mailing list