CVS – Concurrent Version System – Notes

CVS – Concurrent Versions System

These notes are taken from the free CVS book listed below. It’s a great book and gets you and going very quickly. For the most part, cvs is quick to learn, easy to use and therefore great for small software projects. It may not have all the other features that newer version control systems have but for small projects it’s good enough. It is not used for binary files. But you can put binary files in the system. It only makes sense to me if you are version controlling graphical images. But that leads to a deeper discussion not appropriate for this document.

http://cvsbook.red-bean.com/
http://cvsbook.red-bean.com/OSDevWithCVS_3E.pdf

2 Install cvs:

yum search cvs
yum install cvs.i386
Possible others you may want to install:
cvsutils.noarch
cvsweb.noarch
check yum output for others.

3 Create a repository

However, if you want to serve revisions from your machine, you have to create a repository there. The command to do that is

$ cvs -d /usr/local/newrepos init

where /usr/local/newrepos is a path to wherever you want the repository to be

Don’t confuse the CVSROOT environment variable introduced in Chapter 2 with this CVSROOT

sub-directory in the repository. They are unrelated; it is an unfortunate coincidence that they share the same name. The former is a way for users to avoid having to type -d <repository-location> every time they use CVS; the latter is the administrative sub-directory of a repository. Once the repository is created, you must take care of its permissions. CVS does not require any particular, standardized permission or file ownership scheme; it merely needs write acess to the repository. However—partly for security reasons, but mainly for your own sanity as an administrator—we highly recommend that you take the following steps:

1. Add a Unix group “cvs” to your system. Any users who need to access the repository
should be in this group. For example, here’s the relevant line from a typical machine’s
/etc/group file:
cvs:*:105:mosheb,kfogel,anonymous,jrandom
2. Make the repository’s group ownership and permissions reflect this new group:
$ cd /usr/local/newrepos
$ chgrp -R cvs .
$ chmod ug+rwx . CVSROOT

You may want to set the setgid bin on the repository. That way all new added files for that project created through cvs are
created with the same group.
That’s one way.
The other way is to create a new directory named after the project under the cvs repository.
Then set the group ownership to the group that is controlling that project. That way you can have different groups in controlling
different projects. But this means that the System Administrator will get requested to create those project directories.
If all you are doing it managing your stuff and you are the only developer, these issues become somewhat academic.

4 Setting the environment:

cvs -d /usr/local/cvs command

Let’s look at the pserver access method, which stands for “password-authenticated server”:

$ cvs -d :pserver:jrandom@cvs.foobar.com:/usr/local/cvs login
(Logging in to jrandom@cvs.foobar.com)
CVS password: (enter your CVS password here)

Of these, the ext method is probably the most commonly used. If you can log in to the server with rsh or ssh, you can use the ext method. You can test it like this:

$ rsh -l jrandom cvs.foobar.com
Password: enter your login password here

Okay, let’s assume you successfully logged in and logged out of the server with rsh, so now you’re back on the original client machine:

$ CVS_RSH=rsh; export CVS_RSH
$ cvs -d :ext:jrandom@cvs.foobar.com:/usr/local/cvs command

The first line sets (in Unix Bourne shell syntax) the CVS_RSH environment variable to rsh, which tells CVS to use the rsh program to connect. The second line can be any CVS command; you will be prompted for your password so CVS can log in to the server. For Windows, try this:

C:\WINDOWS> set CVS_RSH=rsh

The rest of the tour will use the Bourne syntax; translate for your environment as necessary.

To use ssh (the Secure Shell) instead of rsh, just set the CVS_RSH variable appropriately:

$ CVS_RSH=ssh; export CVS_RSH

If you use only one repository and don’t want to type -d repository each time, just set the CVSROOT environment variable (which perhaps should have been named CVSREPOS, but it’s too late to change that now), like this

$ CVSROOT=/usr/local/cvs
$ export CVSROOT
$ echo $CVSROOT
/usr/local/cvs
or like this:
$ CVSROOT=:pserver:jrandom@cvs.foobar.com:/usr/local/cvs
$ export CVSROOT
$ echo $CVSROOT
:pserver:jrandom@cvs.foobar.com:/usr/local/cvs

5 creating projects

Putting a new project into a CVS repository is known as importing. The CVS command is

$ cvs import

except that it needs some more options (and needs to be in the right location) to succeed. First, go into the top-level directory of your project tree:

$ cd myproj
$ ls
README.txt a-subdir/

The general syntax of an import command is:

$ cvs import -m "log msg" projname vendortag releasetag
$ cvs import -m "initial import into CVS" myproj jrandom start

Then you mve your dirctory to somplase trasient like /tmp/your_initials/projectname

Then checkout the project

$ cvs checkout projectname

6 Commands you will use most often:

These commands are roughly listd in the order of frequency, high to low, in which you will use them

$ cvs update
$ cvs diff
$ cvs commit
$ cvs status
$ cvs add
$ cvs log
$ cvs import
$ cvs remove
$ cvs tag

7 Common Headers

7.1 php

<?php
/*
********************************************************************************
* Author :
* Purpose :
* Date Created:
********************************************************************************
* CVS Information
********************************************************************************
* $Author: $
* $Source: $
* $Date: $
* $Id: $
* $Revision: $
********************************************************************************
* Notes
********************************************************************************
*/
?>

7.2 perl

: # use perl -w
eval ' PERL=/usr/local/bin/perl;
[ -x $PERL ] || PERL=/usr/bin/perl;
[ -x $PERL ] || PERL=/etc/Tivoli/ActivePerl/bin/perl;
exec $PERL -S $0 ${1+"$@"}'
if 0;
#! /usr/bin/perl # just a comment now
################################################################################
# Author :
# Purpose:
# Date :
################################################################################
# CVS Information
# $Source: $
# $Author: $
# $Date: $
# $Id: $
# $Revision: $
################################################################################
# Notes
################################################################################
7.3 ksh
#!/bin/ksh
################################################################################
# Name :
# Purpose:
# Date :
################################################################################
# CVS Information
# $Source: $
# $Author: $
# $Date: $
# $Id: $
# $Revision: $
################################################################################
# Notes:
################################################################################

 

Comments are closed.