svnbranchsubclipsetrunk

Eclipse project with Subclipse: Introduce trunk and branches


I have a project in my workspace (without trunk and branches) and need to create a copy of the current release for providing bug fixes for this release while working on a new feature, as described here: http://nedbatchelder.com/text/quicksvnbranch.html. What is the recommended way of doing this without affecting repository's main structure and the checked out projects on the machines of other developers?


Solution

  • If you did not establish some structure when you created your repository you cannot do so now without having some impact on existing users. The repository is like a file system. You can create the structure now, but because it will involve moving around where your project is stored it will require users to either checkout from the new location, or use the switch option to update their existing checkout to point at the new location.

    How do you do it?

    1) Use svn mkdir to create the trunk and branches folder in the repository. You can do this from Subclipse from the SVN Repositories view using the Create Folder option.

    2) You then need to move any files and folders that are in the root of your repository to the trunk folder, so that trunk is now the root of your project. I would do this using the command line:

    $ svn mv url://host/repos/folder1 url://host/repos/trunk -m "Move folder1 to trunk"
    
    $ svn mv url://host/repos/folder2 url://host/repos/trunk -m "Move folder2 to trunk"
    
    $ svn mv url://host/repos/file1 url://host/repos/trunk -m "Move file1 to trunk"
    

    When you are done, the root of your repository show now only contain the trunk and branches folders.

    3) On your existing checked out project in Eclipse, do Team > Switch. Use the browse button to select the trunk folder in the dialog and click OK. This will update your working copy in place so that it points at the new location.

    All users will need to do step 3.

    Finally, you are now ready to create branches. Just copy trunk to the branches folder to create a branch. You can do this from Eclipse with Team > Create Branch

    Use Team > Switch to switch back and forth between your branches and trunk.

    Use Team > Merge to merge changes from trunk to a branch or vice versa.