4

A few weeks ago we migrated from CVS to Subversion. I choosed to create each project or folder (whatever they are called in CVS) as a seperate project in Subversion and ended up with the recommended structure:

[svn_path]/Server/
  -- ProjectA/
     -- branches
        -- branch1
        -- branch2
     -- trunk
  -- ProjectB
     -- branches
        -- branch1
     -- trunk

Now we have realized that this is not really the way to do it in our project. The different projects have strong dependencies, and code is being committed to many projects at one time. Reintegrating from a branch makes this a big issue, and we really want to reorganize the repository so the projects are combined like this:

[svn_path]/Server/
    -- branches
       -- branch1
          -- ProjectA
          -- ProjectB
       -- branch2
          -- ProjectA
    -- trunk
       --ProjectA
       --ProjectB

How is this done?

To give more details, I will just add that in CVS we had one branch for all our code. With the layout choosed in svn we got a branch for each project but all with the same name. Now what I want to get back to is all code should be under the same branch, so each developer only has to look at one branch to see what changes to merge.

By the way - I have googled etc. and not found a description that fitted my intelligence ;-)

homaxto
  • 153
  • 1
  • 7

2 Answers2

4

I'm assuming that you have everything in a single repository. This makes things a lot easier.

This is surprisingly easier than you'd think:

svn mkdir /svn/path/Server/branches/
svn mv /svn/path/Server/ProjectA/branches/ /svn/path/Server/branches/ProjectA/
svn mv /svn/path/Server/ProjectB/branches/ /svn/path/Server/branches/ProjectB/
svn mkdir /svn/path/Server/trunk/
svn mv /svn/path/Server/ProjectA/trunk/ /svn/path/Server/trunk/ProjectA/
svn mv /svn/path/Server/ProjectB/trunk/ /svn/path/Server/trunk/ProjectB/

You may want to make a copy of your repository to test on first before you try this on your real repository.

David Pashley
  • 23,497
  • 2
  • 46
  • 73
  • Can this be done directly on the repository or should I check the code out first? – homaxto Oct 21 '09 at 14:09
  • You should do it on the repository directly. Again, make sure you test on a copy first. – David Pashley Oct 21 '09 at 14:51
  • Well it looks like it is working - I just have one problem left. I need to add all the branches of all the projects into the same branch folder - and there are duplicates. My problem is that svn mv will not only move the content of [..]/branches but insists on moving the folder also. Thus creating [..]/branches/branches and the second move yields "svn: Path 'branches' already exists" Is it possible to merge branches with the same name? – homaxto Oct 22 '09 at 08:59
  • I have to move each and every branch in every project so I get the desired structure, but it is doable. Now I just fear the tags - there are just to many >:-| svn mv --parents file:///[svn_copy]/Server/ProjectA/branches/branch1/ file:///[svn_copy]/Server/branches/branch1/ProjectA -m "moving" – homaxto Oct 22 '09 at 12:47
  • you could script it with svn ls – David Pashley Oct 22 '09 at 14:07
-1

For what you describe i suggest taking a look at bazaar ( http://bazaar-vcs.org/ ), git ( http://git-scm.com/ ) or mercurial ( http://mercurial.selenic.com/wiki/ ). It looks like you'd have a better use of a distributed vcs than with subversion. I personally switched from svn to bazaar and i'm very happy with it.

sh1ny
  • 535
  • 3
  • 6
  • We choosed svn because we heard that the ones you mention have a steeper learning curve - and until now it has been steed enough - and the fact that we are using Atlassians products which only supports git of the one you mention. Besides what I am struggeling with now could have been avoided if we just had choosen the right layout from the beginning. Would reorganizing have been any easier in bazaar? – homaxto Oct 22 '09 at 12:42
  • Bazaar has a plugin for pulling changes from svn, so migrating from svn to bazaar would be painless. Also, all of the things you need are supported by bazaar - it won't be hard to learn - you can use it the same way as svn, but after a while if you consider you want to use a more advanced approach, it will go just as smooth. Take a look at http://bazaar-vcs.org/Workflows , and you'll see what i mean. – sh1ny Oct 22 '09 at 16:23