Concurrent Versions System Explained
CVS is considered as very powerful revision control software. Even though sub-version has come into the picture recently, CVS is able to find its own place in the development community. The idea behind this article is to introduce the user to CVS and to some of the commonly used commands and options…
Thus we have executed a log-in command and it verifies that the user is authorised to work with this repository. It prompts for a password and then talks to the server to verify the credentials. We need to log in only once from our local machine to a given CVS server. Once the login is successful, CVS stores the password in a file ‘.cvspass’ under the home directory.
Checkout is an important feature with CVS. Checking out a project will create a working copy of it.
$ cvs co cvsexample
Now we will have a directory ‘cvsexample’ on our local machine and that will have a subdirectory called ‘CVS’.
The ‘cvs update’ command can be used to update the working copy.
$ cvs update -dP
Here we have used the ‘-d’ option that checks for new directories and the ‘-P’ option that removes empty directories.
Once we make changes to the files, they need to be checked in so that these will also be visible to the developers. The ‘cvs ci’ (check in) command will send the changes from the working copy into the central repository.
$ cvs ci filename
It is always of great help if we can log the appropriate messages while committing the changes. These log messages serve as an important note for other folks and they will get an understanding of what is going on in a specific project. The ‘cvs log’ command can be used to see the commit logs.
$ cvs log filename | less
New files can be added to the repository by running the ‘cvs add’ command. We need to note here that new files are not visible to the other users before ‘cvs ci’ is executed.
$ cvs add filename
$ cvs ci
New directories are also added in the same manner. But there is no need to run the ‘cvs ci’ command for these.
$ cvs add directory
Files can be removed from the repository using the ‘cvs rm’ command. Before executing this command, we need to physically remove the files from our local file system.
$ rm filename
$ cvs rm filename
We need to note here that the file is not actually removed from the repository, but marked as removed. Thus it is still possible to extract old versions of the file later if required.
It is not possible to remove directories, but we can hide empty directories with the following command.
$ cvs update -P
When we have multiple versions of the file, it is always beneficial to know the differences between two different versions. The following command can be used to see the local changes against the checked-out version of a file.
$ cvs diff -u filename
Suppose we have two versions (say 1.2 and 1.3). The following command can be used to know the differences between them.
$ cvs diff -u -r 1.2 -r 1.3 filename
In CVS, sometimes we will end up with situations where two or more developers try to commit the changes to the same region of the same file. In such a case, CVS notices this and indicates that there is a conflict. The developers then need to manually resolve those conflicts.
This article originally appeared in issue 84 of Linux User & Developer magazine.
Linux User & Developer, one of the nation’s favourite Linux and Open Source publications, is now part of the award winning Imagine Publishing family. Readers can subscribe and save more than 30% and receive our exclusive money back guarantee – click here to find out more.

















What's your opinion?