Renaming files in svn
Occasionally a developer decides a file (and possibly associated classes) should be renamed for clarity or readability.
Subversion handles most file renames transparently. Rename the file locally through Intellij, verify your build and any tests, and commit. svn (unlike certain other vcs's such as cvs) is smart enough to preserve the version history.
The big exception to this is doing a case-only rename. (e.g., "myfile.java" -> "MyFile.java"). Because Windows file systems are case-insensitive, this causes major headaches. Don't do it as described above.
But what if I really need to do a case-only rename?
There are two solutions to this problem:
- Do the rename in two steps. Rename to an intermediate file name first, commit, then rename to the target, and commit again (myfile.java -> myfileA.java, commit, myfileA.java -> MyFile.java, commit)
- Perform the rename directly in the svn repository via command line, or (easier) the Repo Browser in TortoiseSVN, as explained here. (In brief, go to the TortoiseSVN Repo Browser, drill to the file, right click, and rename. Update, and you should pick up the change locally.)
Important notes with either procedure.
- Only do this in trunk. Doing this on a branch will make the developer on merge duty dislike you.
- Verify the build after each step. Depending upon what kind of file you are renaming, you may also have to rename classes.
- Because of the above, you may leave trunk in an unbuildable state during the intermediate steps. It is therefore better to do this after hours, after the dailies have started on Team City, or early in the day so you have time to fix your mess before disrupting anyone else.