Monday, February 4, 2013

Fixing a filename with the wrong case in Subversion


Java convention is that classes begin with an uppercase letter.  Suppose you create a file "foo.java" and want to rename it to "Foo.java".  If you look at the Subversion documentation, you might find the "svn move" command and try something like this:

$ svn move foo.java Foo.java
svn: E155007: Path '.../Foo.java' is not a directory

Huh?

The problem is that Mac OS X and Windows do not respect case differences in filenames, so it looks like you're asking to rename a file to its own name, which doesn't work.  (What that error message means, I have no idea.)

The solution is to rename it temporarily to something different, commit it, then rename it back to the properly cased name:

$ svn move foo.java TempFoo.java
A         TempFoo.java
D         foo.java
$ svn commit -m "temporary rename"
Adding         TempFoo.java
Deleting       foo.java

Committed revision 1145.
$ svn move TempFoo.java Foo.java
A         Foo.java
D         TempFoo.java
$ svn commit -m "rename back"
Adding         Foo.java
Deleting       TempFoo.java

Committed revision 1146.