Guide to CVS
*This document is licensed under the Creative Commons Attribution Share-Alike License 2.0. The original was written for 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.
- Windows/command
set CVSROOT=cvsroot-string
- Unix/bash
export CVSROOT=cvsroot-string
- Unix/csh
setenv CVSROOT cvsroot-string
where cvsroot-string is of the form
```
:protocol:username@server:/path-to-repository</code>. (The
cvsroot-string for anonymous read-only access to dev.w3.org
is To use You will be prompted for your password. (For anonymous access, the
password is To check out files from the repository, first cd to the directory where you want to keep the
files, then type where path is the path to the file/directory you want to
check out or a module name. For example, The (Note that 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. 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.
</html>
=== Basics ===
To create a patch, type The last part (> patch.out) dumps the output of that command
to the file Some reviewers prefer having a bit more context for each of the changes: The 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. If you're creating a new file, you can add that change to the diff as
well. First, open up the Now you can include the new file in your diff by using the Always run the The command for committing changes (“checking in”) to the
repository is similar to the diff command: you list all the files that
have changed: The comment should include the reviewer ( To add a file to the tree, first Then commit the addition as with other changes. If the file is binary, you must To remove a file from the tree, first delete your own copy, then, from
its parent directory, issue the command As with adding files, you must commit this
change. CVS will still keep the revision history for the removed
file.:pserver:anonymous@dev.w3.org:/sources/public
```
</div>
-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
</div>
</html>
### Logging in
cvs login
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</code> environment variable to a reasonable directory
path.cvs -z3 co path
cvs -z3 co CSS
cvs -z3 co CSS/CSS2.1-test-suite/README
-z3
```
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.</p>
-z9 offers a logarithmic improvement in
compression at an exponential cost in CPU time. Therefore, we recommend
```
-z3</code>; that seems to be about optimal in most cases.)cvs diff -pu path/to/file1 path/to/file2 ... > patch.out
patch.out
```
cvs will just print everything to the screen.
</html>
#### More Context
cvs diff -pu8 path/to/file1 path/to/file2 ... > patch.out
8 after the u asks for 8 lines of context
instead of the usual 3.cvs diff -pu8w path/to/file1 path/to/file2 ... > patch.out
</html
#### New Files
CVS/Entries file that's
in the new file's directory. Add the following line to it:/filename/0/dummy timestamp//
-N
option:cvs diff -pu8N path/to/file1 path/to/file2 ... > patch.out
### Committing Changes
cvs diff command and
check it's output before committing your changes to the tree.
You will catch many mistakes before they happen this way.cvs diff -pu path/to/file1 path/to/file2 ...
cvs commit -m "comment" path/to/file1 path/to/file2 ...
r=someone
and the
patch author (patch by foo@example.com
) if written by someone
besides you.cd to its
parent directory then typecvs add filename
cvs add
with the -kb options.cvs add -kb filename
### Removing Files
cvs remove filename