Possible Patch: Allow Renaming to Different Case
Michael Cook
foobarsoft at foobarsoft.com
Mon Apr 25 02:57:44 BST 2005
OK, one more patch for the night (hey this is fun!). I needed to rename
some files to fix their case, but I wasn't allowed to because the
destination file was said to already exist (I'm on OS X, which is case
insensitive). Below is a simple change to allow renaming in the case
that the two filenames are identical ignoring case, which fixes this
bug.
Now I don't know if you want to apply this, as on filesystems that ARE
case sensitive, this could lead to unwanted behavior. In the situation
where one directory has two files with the same name but different case
(README and ReadMe for example), this patch would let you rename README
to ReadMe, overwriting the original ReadMe file without complaining. I
can't think of a simple solution to this problem that can handle both
cases correctly. My only two thoughts are to either check some unique
property of the file to see if the two files are the same (say the
inode number), or to make a check to see if you are on a
case-insensitive filesystem and test the condition in the patch only if
that is true.
--- bzr/bzrlib/branch.py Thu Apr 14 21:50:23 2005
+++ bzr-dev/bzrlib/branch.py Sun Apr 24 20:45:45 2005
@@ -773,7 +773,8 @@
if not tree.has_filename(from_rel):
bailout("can't rename: old working file %r does not exist"
% from_rel)
if tree.has_filename(to_rel):
- bailout("can't rename: new working file %r already exists"
% to_rel)
+ if from_rel.lower() != to_rel.lower():
+ bailout("can't rename: new working file %r already
exists" % to_rel)
file_id = inv.path2id(from_rel)
if file_id == None:
More information about the bazaar
mailing list