views:

423

answers:

3

I have a project on codeplex and I'm trying to reorganise the tree structure so it makes a bit more sense and is easier to work with.

This is my current layout:

TopLevel
|-->src
   |--->ProjectA //This is where all the files are held
         |-->Core //plus three more folders 
|-->MyProject.Core
   |--->trunk
        |-->src // I want to move all the folders and files in ProjectA into here

So I want to move all folders and files under ProjectA to ProjectA.Core/Trunk/src.

I checkout the whole source tree and right-clicked dragged the folders under ProjectA folder and selected "move versioned files here" into the src folder, that marked the folders in Project for deletion but the new files in src still had the green tick next to them and not the blue plus button.

After I commited the changes I had a look in the repo browser and saw that the folders hadn't been moved and were still in the ProjectA folder.

How can I move folders and the files in those folders to a different folder in subversion? Without loosing version history.

I'm using TortoiseSVN.

EDIT: Turns out it must have been codeplex, I moved my project to google code and everything works fine.

+2  A: 

I don't know what I was thinking when I suggested to export and import the files. I think I've been away from TortoiseSVN too long. I recall that tortoise svn actually has a really easy method of moving whole directories. It's not just obvious... but it's not clear why you can't get the result committed correctly to the repository. Presumably you did commit on the parent of all these folders.

Here's the summary: You must select the folder and files you wish to move, and after doing so right click on the selection and drag it with the right button to the new location. You will get a context menu asking if you wish to relocate the files in the repository. This retains the history. Now your old files are marked for deletion and your new files should be marked as added. (I've found the status icons to be... not always representative of the true status). Commit this as one commit. I like to be picky and use check for modifications on the root of the checked out files, and then select exactly which changes I want to commit before doing so.

In the case of just moving one folder like this, open a window that is a parent to this folder, and another window that will be the new parent of this folder. Right click and drag all in one motion. I can't believe it takes this much text to describe a simple mouse action.

dlamblin
Subversion makes it easy to move files and even whole directory trees around at will. The export/import method is totally inappropriate for Subversion. So -1 for your answer. Now, although the original reorg question is easy to do with the Subversion command line client, I haven't run across an easy way to do it with TortoiseSVN.
Greg Hewgill
Ok, your update no longer suggests export/import and my previous comment no longer applies so +1. :)
Greg Hewgill
I have tried what both you and Greg have suggested but after I commit it doesn't delete the folders or add the new ones. I think it might be a problem on the codeplex end because even if I move the folders in the repo browser it doesn't move the folders. This is starting to make a real mess of my commit history :(
Nathan W
After I do a commit all I see in the log for the revision is "Added {folder}/{subfolder}/..Svnbridge/{folderName}" but that's all. It doesn't show any files being deleted or added.
Nathan W
I don't have Windows or TortoiseSVN to try this on now. But I think it's sounding like an issue with the repository, not what you're doing on the client side.
dlamblin
A: 

The standard strategy for dealing with nasty moves is, in the worst case, create all the new directories, move only the files from the old directories to the new directories, and then remove all of the old directories. This should get around almost any problem you encounter, and you can take shortcuts (moving entire directories and or trees) where that does work.

This will preserve history on all files. It will not preserve history on directory creations, but usually this is something you can live with, since you do have history for all of the file moves, which include the old and new directory names.

Curt Sampson
Looks like I might have to do it that way :'(. Because trying to move all these folders around feels like it's going to break stuff.
Nathan W
You can easily move directories around in Subversion without losing history, just as you can move files around without losing history.
Greg Hewgill
Actually, sometimes it's not so easy to move directories, and you're forced to do the moves across several commits. Say, for example, you want to move foo, excepting foo/src, to bar, and foo/src to foo. You can't do this in a single commit unless you don't do directory moves.
Curt Sampson
+2  A: 

This type of reorganisation is easy to do with the Subversion command line client, which might be a viable option for you. Here's the commands that would do it (from the TopLevel directory):

svn mv src/ProjectA MyProject.Core/trunk/src/
svn ci -m "relocate ProjectA"

You can also combine both commands into one by using URLs as the source and destination, see the svn mv documentation for details.

I haven't found an easy way to do this sort of thing with TortoiseSVN, so when I need to I just use the command line client to do it.

Greg Hewgill
I'll download that and give it a try. Sometimes it's better just to stick with command line and ditch the GUI.
Nathan W
why does this have a downvote?
Nathan W