Monday, Feb 26, 2007
SVN (Subversion) Shared Project Repositories
Today, you will learn how to access a group repository on the CS server which will make it easier for you to manage the source files of your group project. To get started, here is what you need to do:
- Follow the instructions at http://subclipse.tigris.org/install.html to download and install the Subclipse plugin for Eclipse. In Step 4, use one or the other of the Name/URL pairs, not both. In Step 6, you may need to unclick the checkbox "Show the latest version of a feature only" if you are using a slightly older version of Eclipse. After installation, Eclipse should restart itself.
- (This step may only be necessary when running Eclipse in Windows.) When Eclipse starts (or restarts), go to the "Window" menu and choose "Preferences..." (at the bottom). Expand the "Team" item in the dialog box, and select "SVN". In the button group labeled "SVN interface", choose "SVNKit (Pure Java)". Press the "OK" button.
- From your Eclipse workspace. Choose "New..." -> "Project" from the File menu. Under the new project dialog box, don't select "Java Project" as usual. Instead, expand the choices under the "SVN" folder and choose "Checkout Projects from SVN". Then click "Next".
- On the next dialog, select the "Create a new repository location" and click "Next". Under "Url" type "svn+ssh://cs.berry.edu/Users/svn/classes/2007_spr/csc121/group1" (or "...group2", depending on which group you are in). Then click "Next" at the bottom of the dialog.
- You will get a dialog box asking you to enter SSH credentials - enter your username on the server and password. (If you are doing this on your own computer, you may choose to "Save information" - otherwise, do not, as it will save your password.) Click "OK".
- A further dialog box will ask you to Enter SVN Author Name. Under author name, use your login name for the server, for example "nhamid", NOT "Nadeem Abdul Hamid" or whatever your real name is. You may choose to save this setting so that you don't need to enter it again.
- In the next dialog ("Select Folder..."), select the "files" folder and click "Next".
- Finally, in the "Check Out As..." dialog, choose the "Check out as project configured using the New Project Wizard" and click "Finish".
- Now, the New Project Wizard should start, as if you are creating a new project. Go through as usual, selecting "Java Project", then after clicking "Next", give it a name (which can be anything you want, like "Group 1 Project") -- this name is only for your workspace, it does not need to correspond to the name of the folder in the SVN repository.
- When the project dialog box finishes, you should see your newly created project, with a file already in it, called "test.txt".
- If Eclipse ever asks you to type in your username with relation to the Subversion repository, make sure you use exactly your login name on the server.
What just happened? SVN (Subversion) is a
When you check out a project from the SVN repository, it copies the latest versions of the files in the repository onto your local hard drive. You can make changes to the files in your Eclipse workspace. After editing the files, after you are satisfied that there are no errors, you can 'commit' your modifications to the repository. The others on your team (and yourself) can run an update command every now and then to get the latest versions of all the files from the repository.
SVN does not automatically prevent two people from making changes to the same file and committing them. This can cause conflicts in the version that is stored on the repository. SVN provides some fancy algorithms to try and merge the changes in a meaningful way. To maintain your sanity, you will want to avoid all this. Before beginning to edit a file, you should use the "Team" menu (right-click on a file) to choose the "Lock" operation on a file. This way, if someone else in your group has already locked a file for editing, you will not be able to do so.
When you are done making changes to a file and are ready to share them with the others on your team, choose the "Commit" option on the "Team" menu for a particular file, or for the entire project. (Don't forget to "Unlock" the file too, if you locked it.)
To download the changes that others have made to the repository into your local workspace, choose the "Update" command from the "Team" menu.
Helpful hints for working with CVS: