Svn – Moving a folder in SVN

svntortoisesvn

This is on Win2k3sp2, using TortoiseSVN 1.6.5 and SlikSVN 1.6.3.

I have a folder in a repo, call it /a/b, which I want to become /a/c/d in the same repo. I have tried just moving the folder and renaming it, and then committing, and apparently it gets confused, because the .svn folder thinks it's still under the old name, and if it does work, it's a two-commit thing where /a/b is deleted and /a/c/d is brand new, which is no good, because then I lose the history attached to each file.

I started poking around and found "relocate," which comes with a huge warning and convinces me not to use it. Then there's "switch," which, although I thought "relocate" was a more intuitive way of describing what I wanted to do, seemed to be the appropriate option. So I did that, and it took a long time, even though there were only a few files within /a/b (like maybe 8 folders, each containing a file or two), and now:

  1. /a/b is still there
  2. half the folders in /a/b are gone
  3. the remaining folders in /a/b give me an error when I try to look inside them: "/a/b/e is not accessible. Access is denied."
  4. /a/c/b (not /a/c/d as I had told it!) was created but stayed empty
  5. I tried an update and now some folders are back in /a/b, but not all

My question then is in two parts:

  1. How do I clean this up?
  2. What's the proper way to move a folder as I described?

Best Answer

Your problem is having used the wrong command; 'Switch' does the exact complement of what you wanted - it changes the repository location your working copy 'points at', without changing the repository. (Switch then commit would have produced some result, but in a really broken way which isn't what you meant. You were right; the tempting-sounding 'Relocate' is a special case of 'Switch', and should be avoided for the same reason.)
The 'Update' command then updated the working copy to match what was currently in the repository at the 'new' location - nothing!

Subversion doesn't have a true move/rename yet. The subversion-safe way to do it is to copy and then delete. TortoiseSVN includes a handy 'move' option which does a copy-and-delete as one operation.

The easiest way to do what you wanted:
1. Open repo-browser in TortoiseSVN.
2. Right-click and drag the folder from its old location to the new one.
3. Select 'Move' from the context menu.

This also works inside your working copy, and is the safe Tortoise/Subversion way to move or rename files and folders in the wc without losing history.