Tutorial :Is there a clean way to move / to /trunk?



Question:

I made the mistake of creating a Subversion repository without the usual trunk, branches, and tags directories. That is, the root directory of the project maps to the root directory of the repository. Now I want to create a feature branch, but there's no good place to put it. What I'd like to do is move / to /trunk, preserving its properties and history. Am I out of luck?


Solution:1

The clean way to do this is using svnadmin to dump out the whole repository using

svnadmin dump  

Then create a new repository with the trunk directory at the root, and reload the dump with

svnadmin load --parent-dir trunk

If you do an svn move then that will mess things up if you ever update back to a revision before the move, since the files will move back to their previous location, which is probably not what you want.


Solution:2

Used therefromhere's answer, which worked fine, but wanted to add the commands including the parameters, i.e. as executed on the svn server's command line:

  1. Dump your existing repository into a file:

    svnadmin dump /path/to/myrepo/ > /some/dir/myproject.svndump  
  2. Create a new repository:

    svnadmin create /path/to/mynewrepo/  
  3. Add the trunk/ folder and commit it, in the working copy directory:

    mkdir trunk; svn add trunk; svn commit trunk -m "Add: trunk folder"  
  4. Load the dumpfile into the new repository using trunk as parent-dir:

    svnadmin load --parent-dir trunk /path/to/mynewrepo/ < /some/dir/myproject.svndump  


Solution:3

You need to create /trunk and do an svn move of all contents of root inside the trunk and then commit.

After that you'll switch your working copy to /trunk.


Solution:4

The easiest way would be to create a 'trunk' directory, then move everything else into it. You'll have to copy any properties manually, but it shouldn't be a big deal. The history is per-file, so it should remain.

The other issue to consider is whether anybody else has the repository open. It'll be difficult to merge, so make sure everyone has their changes checked in before you do this.


Solution:5

Can’t you just create the trunk dir and move everything from / to trunk?


Solution:6

As the other answers point out, just doing a svn mv into the trunk directory will do this. To then update your working copy, check out the svn switch command.


Solution:7

No just create a trunk folder and move all the contents of the root to it. You can do it from explorer or through the repo-browser, the history will persist.


Solution:8

There are some gotcha's or limitations with some of the discussed approaches. The post below discusses another approach, which involves dumping the repo and editing the file paths. This has the benefit that moved files will be properly modified too.

http://dotslashstar.blogspot.com/2011/06/svn-hack-insert-missing-trunk-root.html


Solution:9

Quick example of how I did it.

I wanted to move file:///svn/myRepo to file:///svn/myRepo/trunk

cd /    svnadmin dump /svn/myRepo > my.dump    killall svnserve    sudo rm -r -f /svn/myRepo    svnadmin create /svn/myRepo    svnserve -d -r /svn    svn mkdir file:///svn/myRepo/trunk -m "Created trunk dir"    svnadmin load /svn/myRepo --parent-dir trunk < my.dump  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »