How to setup a subclipse project to branch/tag



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2007/03/how-to-setup-subclipse-project-to/

You should be redirected in 2 seconds.



I've read that branching/tagging is one of the nice features of SVN (See Mark Phippard's blog and the subversion book). However, it took me a little while to figure out how to setup my directory structure with the recommended "trunk", "branches", and "tags" folders. These are my basic step-by-step notes for how I setup my Subclipse project and then created a branch. This assumes you've already installed Subclipse and set up a repository. If you have not done that, see How to install Subversion (SVN) with Eclipse on Windows.
  1. Add your Eclipse project to the repository in a "trunk" folder
    • Start with an Eclipse project named "myproject"
    • In the "Navigator" window, right-click on your project, select "Team" > "Share Project..."
    • Select "SVN" and click "Next"
    • Select your repository. (This tutorial assumes it is located at "svn://localhost".) Click "Next".
    • In the "Enter Folder Name" dialog, select the "Use specified folder name" option and enter "myproject/trunk". The "URL:" box should show something like "svn://localhost/myproject/trunk". Click "Next".
    • Click "Finish". A new dialog will open. Select the files to commit, enter a comment, and click "OK". I got the following output in the "Console" window:
          Filesystem has no item
      svn: URL 'svn://localhost/myproject/trunk' non-existent in that revision
      
          Bad URL passed to RA layer
      svn: URL 'svn://localhost/myproject' non-existent in revision '234'
      
      mkdir -m "Initial import." svn://localhost/myproject
      mkdir -m "Initial import." svn://localhost/myproject/trunk
      checkout -N -r HEAD svn://localhost/myproject/trunk
          Checked out revision 236.
      add -N C:\path\to\myproject\.settings
          A         C:/path/to/myproject/.settings
      add -N C:\path\to\myproject\.settings\org.eclipse.cdt.core.prefs
          A         C:/path/to/myproject/.settings/org.eclipse.cdt.core.prefs
      add -N C:\path\to\myproject\.cdtbuild
          A         C:/path/to/myproject/.cdtbuild
      add -N C:\path\to\myproject\.settings\org.eclipse.cdt.managedbuilder.core.prefs
          A
      C:/path/to/myproject/.settings/org.eclipse.cdt.managedbuilder.core.prefs
      add -N C:\path\to\myproject\.cdtproject
          A         C:/path/to/myproject/.cdtproject
      add -N C:\path\to\myproject\.project
          A         C:/path/to/myproject/.project
      commit -m "Initial import." C:/path/to/myproject/.cdtbuild C:/path/to/myproject/.cdtproject C:/path/to/myproject/.project C:/path/to/myproject/.settings C:/path/to/myproject/.settings/org.eclipse.cdt.core.prefs C:/path/to/myproject/.settings/org.eclipse.cdt.managedbuilder.core.prefs
          Adding         path/to/myproject/.cdtbuild
          Adding         path/to/myproject/.cdtproject
          Adding         path/to/myproject/.project
          Adding         path/to/myproject/.settings
          Adding         path/to/myproject/.settings/org.eclipse.cdt.core.prefs
          Adding         path/to/myproject/.settings/org.eclipse.cdt.managedbuilder.core.prefs
          Transmitting file data ...
          Committed revision 237.

  2. Create "branches" and "tags" folders in the repository
    • Switch to the "SVN Repository Exploring" perspective. (From the "Window" menu, select "Open Perspective" > "Other...". Select "SVN Repository Exploring" and click "OK".)
    • In the "SVN Repository" window, expand the tree, and right-click on "myproject", select "New" > "New remote folder".
    • In the "Create a new remote folder" dialog, expand the tree and select "myproject". For "Folder name:", enter "branches". Click "Next".
    • Enter a comment and click "Finish".
    • Expanding the "myproject" folder now shows the "branches" and "trunk" subfolders.
    • I got the following output in the "Console" window:
      mkdir -m "Created branches folder." svn://localhost/myproject/branches
    • Repeat these steps to create a "tags" folder.

  3. Create a branch
    • Switch back to the previous perspective.
    • Commit any changes you want in the branch.
    • In the "Navigator" window, right-click your project and select "Team" > "Update"
    • Right-click your project and select "Team" > "Branch/Tag..."
    • In the "Copy (Branch/Tag) dialog, in the "To URL:" textbox, enter "svn://localhost/myproject/branches/mybranch". (The "From WC at URL:" box should read "svn://localhost/myproject/trunk".)
    • Leave the "HEAD revision in the repository" option selected, enter a comment, and click "OK".
    • I got the following output in the "Console" window:
      copy -rHEAD svn://localhost/myproject/trunk svn://localhost/myproject/branches/mybranch
  4. Switch your working copy to the branch
    • You can now switch your working copy between the trunk and the branch.
    • Right-click your project and select "Team" > "Switch to another Branch/Tag..."
    • In the "To URL:" textbox, enter "svn://localhost/myproject/branches/mybranch". Click "OK".
    • I got the following output in the "Console" window:
      switch svn://localhost/myproject/branches/mybranch C:/path/to/myproject -rHEAD
          At revision 239.
  5. You should now be able use the features discussed in Enhanced Support for Branches and Tags in Subclipse
Branching steps were taken from How to branch with Subclipse.

No comments:

About

This is my *OLD* blog. I've copied all of my posts and comments over to my NEW blog at:

http://www.saltycrane.com/blog/.

Please go there for my updated posts. I will leave this blog up for a short time, but eventually plan to delete it. Thanks for reading.