Penguin
Note: You are viewing an old revision of this page. View the current version.

Acronym for Concurrent Versioncontrol System. Not to be confused with CSV.

A way of allowing multiple people work on one set of files at the same time and have changes merged in and history and versions kept (much like the wiki).

CVS started off as a couple of shell script wrappers around RCS and diff3(1), and it's evolved into something much much more.

It's starting to show its age now however as it's starting to have a few design limitations.

cvs is invoked by using the cvs(1) command.


If you get a message such as

2402/path/to/repository: no such repository

then it means that your client is too old, and doesn't understand "host:port" being part of the pserver path (eg cvs -d :pserver:hostname:2402/path/to/repository). Upgrade to a newer (1.11.x) version. Version 1.10 (distributed with OSX and solaris for example) has this problem.


Existing documentation supporting CVS

Coriolis Open Press Open Source Development with CVS. Its not all the chapters, but its the relevant ones. The non-free chapters regard the philosophy behind cvs in open source, or something. Direct link to postscript and html. Online copy.


there are 3 commands you need to understand to use cvs:

  1. cvs checkout
  2. cvs update
  3. cvs commit

:)

(There are a few other commands you need if you want to set up a repository, but the above are all you need to get code out of and into an existing repository).


Here are some examples from the Greenstone source code. (GreenStone is GPL'd digital library management software from the Computer Science department at WaikatoUniversity).

1) You need to "checkout" the source code. To check it out, you need to tell cvs where the "repository" is kept. pserver is the method used for anonymous, read-only access to the repository. The newer way is to use ssh.

$ CVSROOT=:pserver:cvs_anon@cvs.scms.waikato.ac.nz:/usr/local/global-cvs/gsdl-src $ export CVSROOT $ cvs checkout gsdl

(If we had a account on that machine for write access, the environment variables would be slightly different
$ CVS_RSH=ssh ; export CVS_RSH $ CVSROOT=:ext:username@server:/directory/to/repository

)

This particular root directory allows anonymous, read-only checkout. You would need a username and password on that particular machine to have write access.

2) Make your own changes to the source code.

$ dd if=/dev/random of=a_source_file.cpp bs=1k count=$RANDOM

(I swear this is how some of our 4th years come up with their code...)

3) Now, you can use cvs to see how your stuff differs from everyone else's, and how to get everyone else's changes into your checked out version.

src/gsdl/perllib/plugins$ cvs update ? HTMLPlug.pm-readme ? mht cvs server: Updating . P !ConvertToPlug?.pm M HTMLPlug.pm P !WordPlug?.pm

P means "patched"; my version was patched to be updated to other people's changes that they have committed. M means locally modified (ie by me).

You can see what is different between my version and the current checked in version

src/gsdl/perllib/plugins$ cvs diff HTMLPlug.pm Index: HTMLPlug.pm =================================================================== RCS file: /usr/local/global-cvs/gsdl-src/gsdl/perllib/plugins/HTMLPlug.pm,v retrieving revision 1.58 diff -r1.58 HTMLPlug.pm 524c524 < $tmptext = s/\s\S*$/…/; ---

$tmptext = s/\s\S*$/…/; # horizontal ellipsis ...

705,707c705,707 < $$textref = s/&(lt|gt|amp|quot|nbsp);/&z$1;/go; < $$textref = s/&([^;?+);/&ghtml::getcharequiv($1,1)/gseo; < $$textref = s/&z(lt|gt|amp|quot|nbsp);/&$1;/go; ---

# $$textref = s/&(lt|gt|amp|quot|nbsp);/&z$1;/go;

$$textref = s/&([^;?+);/&ghtml::getcharequiv($1,0)/gseo;

# $$textref = s/&z(lt|gt|amp|quot|nbsp);/&$1;/go;

So this diff shows that I added a comment to line 524, and commented out lines 705 and 707 (and changed line 706). You may or may not recognise this gibberish as Perl code...

4) Other cvs commands I find very useful include:
cvs status

src/gsdl/perllib/plugins$ cvs status HTMLPlug.pm =================================================================== File: HTMLPlug.pm Status: Locally Modified

Working revision: 1.58 Repository revision: 1.58 /usr/local/global-cvs/gsdl-src/gsdl/perllib/plugins/HTMLPlug.pm,v Sticky Tag: (none) Sticky Date: (none) Sticky Options: (none)

cvs annotate (this has been trimmed for brevity)

src/gsdl/perllib/plugins$ cvs annotate HTMLPlug.pm (.... trimmed ....) 1.7 (sjboddie 06-Dec-99): # if no title use first 100 characters 1.7 (sjboddie 06-Dec-99): my $tmptext = $$textref; 1.43 (jrm21 21-May-01): $tmptext = s/<\/([^>?+)><\1>//g; # (eg) </b><b> - no space 1.30 (say1 14-Oct-00): $tmptext = s/<[^>?*>/ /g; 1.56 (jrm21 11-Jul-02): $tmptext = s/(?:&nbsp;|\xc2\xa0)/ /g; # utf-8 for nbsp... 1.43 (jrm21 21-May-01): $tmptext = s/^\s+//s; 1.16 (gwp 22-Jun-00): $tmptext = s/\s+$//; 1.14 (gwp 24-May-00): $tmptext = s/\s+/ /gs; 1.56 (jrm21 11-Jul-02): $tmptext = s/^$self->{'title_sub'}// if ($self->{'title_sub'}); 1.56 (jrm21 11-Jul-02): $tmptext = s/^\s+//s; # in case title_sub introduced any... 1.30 (say1 14-Oct-00): $tmptext = substr ($tmptext, 0, 100); 1.14 (gwp 24-May-00): $tmptext = s/\s\S*$/.../; 1.15 (sjboddie 20-Jun-00): $doc_obj->add_utf8_metadata ($section, $field, $tmptext); 1.33 (paynter 02-Nov-00): print $outhandle " extracted \"$field\" metadata \"$tmptext\"\n" 1.36 (sjboddie 18-Jan-01): if ($self->{'verbosity'} > 2); 1.16 (gwp 22-Jun-00): next; (.... trimmed ....)

This shows each line (as checked in) of the file, showing when that line was last edited, who by, when, and which version. So if you make a stuff-up, everyone else knows who to blame!

5) Put my improvements back into the main repository! (You should always do an update just before doing this, in case someone else has made a change since you last checked).

src/gsdl/perllib/plugins$ cvs commit HTMLPlug.pm


"cvs update" statuses

| A | this file was added to your checked out version by CVS | C | this file has a conflict between your local changes and someone else's committed changes | M | you've modified it and not yet committed it | P | you've modified the file and cvs successfully inserted someone else's recent changes | R | file removed from the main repository | U | updated other people's changes (and you haven't changed this file).


See Also BitKeeper; SubVersion