|
|
|
CS 341
Software Design |
cvs is a version control tool. With cvs, it is easy for you to save versions of your code or other documents. This enables you to back out of changes that don't work out by reverting to an earlier version and also to figure out what has changed between versions, which can be very helpful when software behaves unexpectedly. In group work, cvs is indispensible as it helps group members coordinate their work, but it is also useful for individuals.
Items that are managed by cvs are stored in cvs repositories. A cvs repository contains a collection of files each of which is stored in a format that allows any previous version of that file to be extracted. It does this by maintaining a listing of the first version of your document in its entirety. Each time that you update the cvs file, it determines what has changed and adds a list of the changes to the file. In this way, multiple versions of a file are stored much more compactly than if each version was stored in its entirety.
Before using cvs, you must create a repository and configure Eclipse to know where that repository is. To create a repository for your work, you should enter the following from a Unix prompt:
-> cvs -d <repository-location> init
where <repository-location> should be replaced with the name of the cvs repository you are creating. A reasonable place to put it is in your home directory since you might want to use cvs outside of 341 work once you are comfortable with it, so you might say:
-> cvs -d /home/blerner/cvs init
Note that you must provide an absolute pathname for the location of the repository.
To use cvs, you need to tell Eclipse where the cvs repository exists that you are using. To do this, open the Window menu, select Open Perspective, then Other..., then CVS Repository Exploring.
Now click on the Add CVS Repository icon which is the rightmost icon in the row just above the big empty pane on the left. For host, say babyred.mtholyoke.edu. For repository path, use the same path as you used in the cvs init command. Enter your user id and password. For connection type, select extssh. Then click Finish.
To place a project under cvs control, right click on the project in Eclipse and select Team and then Share Project. Select the repository location you just created, then Next, Next again and then Finish. You may be told that there are resources not under CVS control. Click the Details button. This should show the files in the project you want to commit. If so, click Yes. Then cvs will ask for a commit comment. You should enter a description of this project. When you look at the project in the Package Explorer there should now be an orange rectangle included in the icon assocaite with each item now under cvs control.
You are now ready to start working on your project. Periodically, you should commit your changes. cvs will only be able to revert to versions you have committed. So, whenever you are about to make big changes, or just after you have gotten something working, you should commit your changes. Right click on your project in the Project Browser in Eclipse. Select Team and Synchronize with Repository to find out what has changed. Then Team... Commit to commit those changes.
At some point, you may decide that you have really screwed up and want to start over with a version that you previously committed. To do this right click on the item to restore, select Team... and the Replace With... If you want the previous checked-in version, select Latest from Head. If you want something even older, select Another Branch or Version to find the version of interest.
Eclipse also helps with situations where you want to roll back to an earlier state. Everytime that you save a file in Eclipse, it keeps a snapshot of the file at that point. If you right click on a file and then select Replace With... and Local History, you will get a window that lists dates and times of previous versions that are stored locally (not in your cvs repository). When you click on one of these times, you will have a chance to see the version saved at that time, compare it to your current version, and, if you like, revert to the earlier version. This can be very useful! Give it a try!
There is much more to cvs than this but this is localy you need to get started on an individual project. Eclipse's support is particularly good for helping you compare the version in your Eclipse workspace with what is in cvs using the Team... Synchronize command. You can get more help about cvs by reading Eclipse's help section on working with cvs or the cvs online manual.