Using Toroise SVN and Eclipse

Russell Bateman
last update: 26 January 2010
		
		

This article explains how to set up and use TortoiseSVN, an interface to Subversion on Windows. Ultimately, it's not a formal application run with its own interface, but a plug-in that sensitizes Windows File Explorer to Subversion control of files and directories in chosen subsets of the Windows filesystem.

TortoiseSVN is a solution only for Windows. To employ Subversion for an Eclipse project on Linux or Macintosh, you will need to find a different approach. (See Subversive—Subversion Team Provider for Eclipse.) This will be the topic of another page of notes another time. There are still some relevant comments here for Linux users (see notes below.)

We also cover setting up and using Subversion inside of Eclipse.


Table of Contents

How to set up and use TortoiseSVN
Setting up Subclipse
Using Eclipse Team on projects
Useful links

How to set up and use TortoiseSVN

  1. Download TortoiseSVN and install from http://tortoisesvn.net/download/
  2.  
  3. Create the top-level directory of your managed filesystem.
  4.  
  5. Here is an illustration of TortoiseSVN functionality as it appears in the File Explorer—just right-click in open space or on a file or directory. You will get different functionality depending on the context.

         

     
  6. Check out the repository corresponding to the subfolder open by choosing SVN Checkout.... Then, fill in the URL of repository field and confirm the other information in the Checkout dialog.

  7.  
  8. Enter username and password, click the box to make TortoiseSVN remember your password if you like (otherwise you have to authenticate each and every action), and then find something to do while your files and directories are downloaded.
  9.  
  10. For additional help using TortoiseSVN from the Windows File Explorer, please consult the links at the top of the left-hand navigational thumb found at About TortoiseSVN.
  11.  
  12. If you want integration with the Eclipse IDE, refer to the section below on this topic.

Setting up Subclipse...

To consume repository files through Eclipse (instead of going to Windows File Explorer), you must set up the Subclipse plug-in software. This tutorial was done on Eclipse Galileo.

I've long worked on Linux, and have used Polarion Subversive (and not Subclipse) there. It will be a while before I get to writing about using Subclipse on Linux (and I'll only do that if there's something to say).

  1. Pull down menu Help -> Install New Software...
  2.  
  3. Click on the Add... button. Name this site (non-crucial) "Subclipse" for example. Type in the URL. You can go to subclipse.tigris.org and see what the latest is. I used update_1.6.x, the latest for Galileo as of this date of writing. Click OK.

  4.  
  5. In the principal content region of the Install dialog, there will be three projects. Select each one by checking their boxes. Then click Next.
  6.  
  7. Review and accept the licenses.
  8.  
  9. Click Finish.
  10.  
  11. The plug-ins will be installed. Then you must restart Eclipse.
  12.  
  13. To ascertain if the software installation was successful and is useful, right-click in the Eclipse Package Explorer on a package or file and choose Team. If there are options, then it probably works.

    Here, I've created a quick "Hello world" project whose sources I don't yet have in Subversion. The Team menu option is in place, but will not yet allow me to commit, update, etc.

  14.  
  15. See the Subclipse installation tutorial in the useful links below for this installation on Ganymede and to walk a few steps further than I have here.

Using Eclipse Team menu on projects

In my experience, the best way to set up a new project in Eclipse that will be under source code control is at creation. However, my discussion here presupposes that your project exists already (and not that you're creating it from scratch).

This discussion holds completely for Eclipse work on Linux.

Set up a Dynamic Java Project

  1. In the Package Explorer view, right-click and choose New. If necessary (because it's not one of the "frequent" choices), choose Dynamic Web Project under Web.
  2.  
  3. Name the project.
  4.  
  5. Uncheck the box Use defaulti, then click Browse.

  6.  
  7. Navigate to the top of the filesystem location of your project—already in Subversion. Click OK to establish this path as the directory for the project contents. This will a) operate solely on that path and b) not set up any filesystem structure in your Eclipse workspace for the project. The workspace will, nevertheless, contain information about the project (just no directories or files).
  8.  
  9. Fill out the remaining dialog items as you normally would as well as the information in the following dialogs. After you have done this, the project will be created, use the existing source code out of your repository and be ready for building.

Notes

- Creating a simple Java (not Dynamic Web) project happens similarly, but the dialog box is slightly different; otherwise, it works identically:

- You will find that you can update your copy of what's in the Subversion repository using TortoiseSVN or other Windows approaches (on Windows) or svn on Linux and Macintosh independently of Subversive (i.e. not using Team -> Update from inside Eclipse). All you must do in Eclipse afterward is to right-click on the project affected (by the independent filesystem operation) and choose Refresh.

- You will find Eclipse decoration of files and folders under repository control confusing. When you modify a file, its icon in Package Explorer will be decorated with a black box in the lower right-hand corner. However, other entities you have not (at least not intentially) modified will begin to sport this decoration too. There are reasons for this, but some you must commit and others you must not if you are collaborating on source-code development with other team members.


Appendix: Some useful links