tags:

views:

25

answers:

1

An annoyance that I sometimes come across with SVN is the working copy getting corrupted by one of the .svn folders getting moved from its original location. It doesn't happen often if you're careful and use the proper tools for all moves and renames, but it still somehow happens from time to time.

First, does anyone know if there's a good way to catch the problem before a commit is even done? Cruise control usually catches the problem, but there are plenty of cases it wouldn't catch.

Second, is there a quick and easy way to check for out-of-place .svn folder if I suspect that there is one? I can definitely do it manually by deducing what directory is out of place based on the compiler errors or by diffing the working copy with another clean checkout. But, this seems like a problem that SVN can diagnose in a second by giving me a list of all directories whose parent directory in the working copy doesn't match its parent directory in the repository. There there some way to have SVN give me a list like that?

Thanks.

+1  A: 

The svn status command can help with this.

For example, suppose that I have a directory foo, and in the repository it has subdirectories bar and baz. And suppose that I move baz into bar, without telling SVN. Then, I get:

$ svn status foo/
?      foo/bar/baz
!      foo/baz

The ? for foo/bar/baz indicates that it exists in the local version but not in the repository -- more precisely, that it exists within the foo/bar directory on your local copy, but the SVN information in foo/bar/.svn has no record of it. Similarly, the ! for foo/baz indicates that it exists in the repository (or, more precisely, in the information in foo/.svn), but the actual file/directory in your local copy is missing.

Meanwhile, if the problem is just a .svn folder itself that's gone missing, that will show up like this:

$ svn status foo/
~      foo/quux

That means that foo/.svn says that there should be a foo/quux, and foo/quux exists, but there is no foo/quux/.svn.

Finally, if the problem is that a directory has a .svn that's pointing at somewhere else other than the subdirectory of its parent -- say you've done an svn switch on that directory -- then you'll get this:

$ svn status foo/
    S  foo/quuux

If you're in Windows and using TortoiseSVN, you can get the same information by right-clicking in the top-level directory, and selecting "TortoiseSVN -> Check for Modifications" from the pop-up menu. Things that have been switched (i.e., the wrong .svn directory) will show up as "normal (s)" in their status.

Brooks Moses
exactly what I was looking for
jthg