Calvin seal CS 108: Introduction to Computing
Spring 2006

Using CVS to Work in Multiple Places

You may want to work on your Java code both in the GLUW-lab and on your own machine. This is relatively easy to do with Eclipse so long as you have an active Internet connection.

The tool to get this to work is called CVS, Control Version System. It allows you to keep a "repository" on one machine, access it from anywhere on the Internet, and download your files onto your local machine. This means that if you have a Windows or Mac of your own, you can run Eclipse on that machine and still get at the same files that you edit in the GLU-lab.

Getting Started

Create the Repository

The computers in the Computer Science Department sit behind a firewall which makes them inaccessible from off campus. Fortunately, our CVS solution will work just fine with a CIT machine named "udu".

From the GLUW lab, log onto udu like so in a konsole:

unix-% ssh udu.calvin.edu

You might be asked whether you trust this machine; yes, you do. You'll be asked for your password; give your email password. This password will not show up on the screen in any visible way.

You first need to know the path to your home directory. Students are handled in a non-standard way. Run this command:

unix-% pwd

I get the path /home/jdfrens in response; yours will probably be something like /home2/x/12345678. Remember the path that you get. Whenever you see me using /home/jdfrens, use your path instead.

Now run this command on udu:

unix-% cvs -d directory init
  • directory is the name of a new directory that will act as your repository.

I used /home/jdfrens/cvsroot for my repository; you can certainly do the same (except substitute in your own home-directory path instead of /home/jdfrens).

Once the repositoiry is set up like this, Eclipse will do most of the managerial work for you.

You will only have to do this once.

Leave udu:

unix-% exit

You can close your konsole.

Creating a Connection to Your Repository in Eclipse

You have to get Eclipse to recognize this CVS repository. Here are the steps:

  1. Start up Eclipse.
  2. In Eclipse, select the Window -> Show View -> Other... menu item.
  3. In the new dialog window, select the CVS -> CVS Repository option and hit the OK button.
  4. Now you should see the CVS Repository view in the bottom portion of the Eclipse workspace.
  5. Right click in the CVS Repository view, and select the New -> Repository Location menu item.
  6. In the new dialog that pops up, enter this information:
    • Host: udu.calvin.edu
    • Repository path: the CVS repository directory (i.e., the one you used in the cvs ... init command above)
    • User: your username
    • Password: your udu password
    • Connection type: extssh
    • Use Default Port selected
    • Validate Connection on Finish checked
    • Do not check the Save password box.
    The following picture shows you approximately what your dialog should look like. Several changes, though: replace my username with yours, replace acolyte with udu, and replace /home/jdfrens with your home directory.
    add CVS repository dialog
    Make sure you're connected to the Internet when you do this. In the GLUW-lab, you get this for free; at home, you may have to dial-up first.
  7. Now hit the Finish button.
  8. You might be asked a series of questions about not missing a key for acolyte and questions if it's all right for Eclipse to create various directories. Answer "yes" to these questions; it's creating the security you want.
  9. If all is fine, then you'll see the new repository in the CVS Repository view. If there's a problem, Eclipse will complain; do not keep the repository location, and try again.

You have to run through these steps on every system where you want to access your projects. Since the whole GLU-lab is one system, you have to do it only once there, but you'll have to do this again on your personal computer.

The first time you do this (in the GLUW-lab), you have to add the Hands on Testing Java project to the CVS repository. This is another step that you'll have to do only once:

  1. Select the project that you want to share (e.g., Hands on Testing Java) in the Package Explorer in Eclipse.
  2. Right click on the project, and select the Team -> Share Project... menu item.
  3. In the dialog that pops up, select your CVS repository, and hit the Finish button.

These steps only add the project to the repository. The files in the project are not shared yet! You have to first commit the files, as described in the next section.

Updating and Committing Your Files

If you edit code on one system, be sure to update your project everywhere else. This is done by synchronizing with the repository first, and updating.

After you've worked on your code for a while, you should commit your changes to the repository. This is done by synchronizing with the repository first, and then committing.

In the end a typical work session should go like this:

  1. Synchronize and update the files on your current computer.
  2. Do your work.
  3. Synchronize and commit your changes to the repository.

Synchronizing and updating or committing follow the same basic steps:

  1. Make sure you're connected to the Internet.
  2. In Eclipse, select and right click on the Hands on Testing Java project
  3. Select the Team -> Synchronize with Repository menu item.
  4. You may be prompted for your password; type it in.
  5. You may also be asked if you want to use the "Team Synchronizing perspective"; it's useful, so say "Ok".
  6. If there aren't any changes at all,
    1. Eclipse will notify you of this in a dialog box.
    2. Hit "Ok".
    3. Switch back to the Java perspective.
    4. Continue with your work; you're done updating/committing.
    Otherwise, there must be some changes, either on the local machine (needing a commit) or on the repository (needing an update). Keep on following these instructions.
  7. Explore the tree of changes in the leftmost window. Arrows pointing to the left are newer on the repository (updates); arrows pointing to the right are newer on your current computer (commits); red arrows pointing both directions are conflicts (updates and commits). At the bottom of the screen you will see summary arrows telling you how many updates, commits, and conflicts there are.
  8. Above the tree, there are buttons for "committing changes" and another for "updating".
    • If you follow the workflow indicated above, you should have only updates or commits. Hit the appropriate button, and Eclipse does its work. You'll be prompted for a comment for a commit; type in something instructive (e.g., "wrote project #22").
    • If you have both updates and commits, do the updates first, run all of your unit tests, fix any errors, and then do the commits. And the promise to always follow the workflow described above!
    • If you have conflicts (i.e., files that need to be updated and committed), ask for help. Yes, it's that serious when you don't follow the update-work-commit workflow described above!
  9. If everything updates/commits fine, the tree on the left should indicate that there are no differences between your current machine and the repository. Switch back to the Java perspective, and continue your work.

If you find that there are updates and commits, then you haven't followed the suggested workflow carefully enough. Generally, this shouldn't be a big problem, though; do the updates first, run all of your unit tests to make sure your uncommitted changes don't break anything, and then synchronize and commit.