cs205: engineering software?
20 September 2010
Suppose you and your team are keeping your project in a folder you all have access to. One day you begin working on the project doing your part, and you come up with a brilliant idea! You work for hours writing some new algorithms. Satisfied, you upload your code and begin writing an email to your team explaining what you've done. However, shortly before you update the code, one of you teammates begins working on the project. While you upload your massive changes, he/she writes a couple simple new methods, and then gets hungry and decides to quit for now. So naturally your teammate uploads his/her changes to the project and walks away. But what just happened? All your hard work has been erased before you even finished the email!
This is why you want to use CVS. Itís a way of synchronizing your data so that no one inadvertently overwrites it like in this example. When you use CVS, you will get a warning if your project has been changed while you were working on it. You can then choose what to about the differences, either accept them or overwrite them. CVS can save you many headaches when working on group projects.
This guide will explain how to use the Concurrent Versions System (CVS) in Eclipse.
First, open a new CVS perspective by selecting Window | Open Perspective | Other | CVS Repository Exploring. This will open a new (probably empty) tab on the left side of your screen. Next, create a new location by right-clicking in the CVS tab and selecting New | Repository Location. This will cause a new window to pop up asking for location and authentication info. You will need to enter the following information:
Host: cs-tl1.cs.virginia.edu Repository Path: /home/cvs0X
Where X is your team number. Your team number is 1 if you're with Kei, 2 with Drew, or 3 with Dan. For authentication, your user is your email id (e.g., drm9r) and your password was emailed to you. To connect, change the connection type from pserver to extssh and click finish. Click yes to all the windows that pop up, if any.
A new repository should be added to the tab named extssh:email@example.com:/home/cvs0X. Click the + next to it to expand the tree where you should see HEAD, Branches, Versions, and Dates. Now click the + next to HEAD. This is where your project modules will be kept. A module is like an eclipse project, except they keep track of changes and synchronization. You will notice that CVSROOT is already in the HEAD directory. It will always be there and can be ignored. Now you can either check in or check out your team project.
To add or update your project with CVS, you will need to first be in the java perspective. If you are not already there, switch with Window | Open Perspective | Other | Java (default). This will bring you the normal workbench with your project files on the left side. To commit, right-click on your project and select Team | Commit, or Team | Share Project... if the project has never been commited before. In the comments field, include a short, useful description of your changes. Now, if there was no error, your project has been successfully uploaded into the CVS. If there was an error, it means someone else from you team has made changes and updated your project since you checked it out. To view the changes, right-click on the project and select Team | Synchronize with Repository... and click Yes if/when asked to change your prospective. Now you can see the conflicts between the code you have locally and what is stored on the CVS. For each file where there is a conflict, you have two options. You can either overwrite your teammatesí changes with your own, or accept their changes over yours. To overwrite, right-click on the file and select Override and Commit... Or, you can update your local copy with your teammatesí changes by right-clicking the file and selecting Override and Update. Whenever there are conflicts, you should inspect the differences carefully to ensure you don't lose your changes (or your teammatesí changes).
A quick summary:
Once you or your teammates have committed code to the repository, you can safely work on it at any time by checking it out. Begin by starting up CVS and moving to the HEAD directory as described above. Find the module you want to work on, right-click on it and select Check Out. Now your project is available to you to work on while still being held for safe keeping in the CVS. To begin working, switch to a java perspective by selecting Window | Open Perspective | Other | Java (default). You may now code normally, and when youíre finished simply check in your project as described above.