I need some clarification about the behaviour of "svn switch". I'm using SVN version 1.6.5.
From reading the manual, my understanding of the behaviour is that local changes will be preserved. So I would expect a locally-added file to still exist in my working directory after svn switch
.
However, my colleagues and I have seen several instances where new files get deleted by the switch. Unfortunately, we can't figure out how to reproduce this.
Is there some circumstance (either a feature or a known bug) under which svn switch
deletes locally-added files?
I think it's a bad idea to switch, when you have uncommitted changes. First, commit your local changes to a branch with svn cp . <branch URL>
, and then switch. There may be very tricky situations you can get into otherwise.
Imagine, that in a version you're switching to, the files you added locally already exist, and are completely different. Or, what if you added a whole directory of files, which can't be adequately merged with the files in the version you're switching to. Do you really want that one big conflict?
There's "S" state shown by svn status
, meaning that different parts of your source tree have different versions. It happens exactly when SVN is confused with local changes during a switch. It just gets broken in a middle of switch, and then it's a pain in the neck to recover. Happened to me several times. That's why I always make sure, that my working copy has no local modifications before I run svn sw
.