====== Guide to CVS ====== //This document is licensed under the [[http://creativecommons.org/licenses/by-sa/2.0/|Creative Commons Attribution Share-Alike License 2.0]]. The [[http://developer.mozilla.org/tools/cvs/|original]] was written for [[http://www.mozilla.org/|mozilla.org]].// ===== What is CVS? =====
CVS is the Concurrent Versions System. It lets multiple people work on the same set of project files at the same time without clobbering each others' changes, and it keeps track of who made what changes made to those files. CVS works by keeping a repository—a master copy—of the project files. Each contributor checks out a copy of the project files, makes his/her modifications, and then checks in or commits the changes: CVS compares the contributor's version to the master copy, figures out what changed, and then changes those lines in the master copy to match, ignoring any changes made by other people to other parts of the file. In case of a conflict, CVS aborts the check-in and reports the conflicts so that they can be manually resolved before trying again.
===== Using Command-line CVS ===== ==== Setting $CVSROOT ====Before you can do anything with cvs, you first need to tell it where
to find the repository you're working with. There are two main ways of
doing this: using the $CVSROOT
environment variable or
using the -d
option. Setting the $CVSROOT
environment variable is usually the most convenient because then you
only have to type it once; subsequent cvs
commands will all use that $CVSROOT
setting.
set CVSROOT=cvsroot-string
export CVSROOT=cvsroot-string
setenv CVSROOT cvsroot-string
where cvsroot-string is of the form
:protocol:username@server:/path-to-repository
. (The
cvsroot-string for anonymous read-only access to dev.w3.org
is :pserver:anonymous@dev.w3.org:/sources/public
.)
To use -d
instead, add -d cvsroot-string
as the first argument after 'cvs' in each cvs
command. For example:
cvs -d :pserver:anonymous@dev.w3.org:/sources/public co CSS
cvs login
You will be prompted for your password. (For anonymous access, the
password is anonymous
.) CVS encrypts your passwords in a
.cvspass
file in your home directory, so
you only need to log in once. If CVS complains about you not having
a home directory, it's probably because you need to set the
$HOME
environment variable to a reasonable directory
path.
To check out files from the repository, first cd to the directory where you want to keep the files, then type
cvs -z3 co path
where path is the path to the file/directory you want to check out or a module name.
For example,
cvs -z3 co CSS
cvs -z3 co CSS/CSS2.1-test-suite/README
The -z3
parameter is to cause the files (and diffs) to be
compressed while in transit. This is almost always the right thing to do;
so much so that you should probably just put cvs -z3
in
your $HOME/.cvsrc file
, to make it be the
default on all CVS commands.
(Note that -z9
offers a logarithmic improvement in
compression at an exponential cost in CPU time. Therefore, we recommend
-z3
; that seems to be about optimal in most cases.)
If the -z3 parameter doesn't work, that means you don't have cvs and/or gzip installed correctly. Your life will be much easier if you correct this, rather than omitting that parameter.
==== Creating a Patch ====A patch is a diff file that lists all the changes you've made to your project files so that other people can review your changes, apply them to their own tree and test them, and/or check them in for you. You will need to know the names of all the files you've changed so that you can tell cvs which files to compare. === Basics ===
To create a patch, type
cvs diff -pu path/to/file1 path/to/file2 ... > patch.out
The last part (> patch.out) dumps the output of that command
to the file patch.out
. If you leave it out,
cvs will just print everything to the screen.
=== More Context ===
Some reviewers prefer having a bit more context for each of the changes:
cvs diff -pu8 path/to/file1 path/to/file2 ... > patch.out
The 8
after the u
asks for 8 lines of context
instead of the usual 3.
If you're making a lot of whitespace/indentation changes, it's often helpful to review a patch with all the whitespace changes ignored so you can focus on what actual content has changed.
cvs diff -pu8w path/to/file1 path/to/file2 ... > patch.out
If you're creating a new file, you can add that change to the diff as
well. First, open up the CVS/Entries
file that's
in the new file's directory. Add the following line to it:
/filename/0/dummy timestamp//
Now you can include the new file in your diff by using the -N
option:
cvs diff -pu8N path/to/file1 path/to/file2 ... > patch.out