Version Management
with
CVS
for CVS 1.9
Per Cederqvist et al
Copyright (C) 1992, 1993 Signum Support AB
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the section entitled "GNU General Public License" is included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that the section entitled "GNU General Public License" and this permission notice may be included in translations approved by the Free Software Foundation instead of in the original English.
Up to this point, one of the weakest parts of CVS has been the documentation. CVS is a complex program. Previous versions of the manual were written in the manual page format, which is not really well suited for such a complex program.
When writing this manual, I had several goals in mind:
This manual was contributed by Signum Support AB in Sweden. Signum is yet another in the growing list of companies that support free software. You are free to copy both this manual and the CVS program. See section GNU GENERAL PUBLIC LICENSE, for the details. Signum Support offers support contracts and binary distribution for many programs, such as CVS, GNU Emacs, the GNU C compiler and others. Write to us for more information.
Signum Support AB Box 2044 S-580 02 Linkoping Sweden Email: [email protected] Phone: +46 (0)13 - 21 46 00 Fax: +46 (0)13 - 21 47 00
Another company selling support for CVS is Cyclic
Software, web: http://www.cyclic.com/
, email:
[email protected]
.
CVS is a complex system. You will need to read the manual to be able to use all of its capabilities. There are dangers that can easily be avoided if you know about them, and this manual tries to warn you about them. This checklist is intended to help you avoid the dangers without reading the entire manual. If you intend to read the entire manual you can skip this table.
admin
command
admin
command can cause
CVS to cease working. See section admin--Administration front end for rcs, before trying
to use it.
Roland Pesch, Cygnus Support <[email protected]> wrote the manual pages which were distributed with CVS 1.3. Appendix A and B contain much text that was extracted from them. He also read an early draft of this manual and contributed many ideas and corrections.
The mailing-list info-cvs
is sometimes
informative. I have included information from postings
made by the following persons:
David G. Grubbs <[email protected]>.
Some text has been extracted from the man pages for RCS.
The CVS FAQ by David G. Grubbs has provided useful material. The FAQ is no longer maintained, however, and this manual about the closest thing there is to a successor (with respect to documenting how to use CVS, at least).
In addition, the following persons have helped by telling me about mistakes I've made: Roxanne Brunskill <[email protected]>, Kathy Dyer <[email protected]>, Karl Pingle <[email protected]>, Thomas A Peterson <[email protected]>, Inge Wallin <[email protected]>, Dirk Koschuetzki <[email protected]> and Michael Brown <[email protected]>.
This manual is known to have room for improvement. Here is a list of known deficiencies:
I hope that you will find this manual useful, despite the above-mentioned shortcomings.
Linkoping, October 1993 Per Cederqvist
CVS is a version control system. Using it, you can record the history of your source files.
For example, bugs sometimes creep in when software is modified, and you might not detect the bug until a long time after you make the modification. With CVS, you can easily retrieve old versions to see exactly which change caused the bug. This can sometimes be a big help.
You could of course save every version of every file you have ever created. This would however waste an enormous amount of disk space. CVS stores all the versions of a file in a single file in a clever way that only stores the differences between versions.
CVS also helps you if you are part of a group of people working on the same project. It is all too easy to overwrite each others' changes unless you are extremely careful. Some editors, like GNU Emacs, try to make sure that the same file is never modified by two people at the same time. Unfortunately, if someone is using another editor, that safeguard will not work. CVS solves this problem by insulating the different developers from each other. Every developer works in his own directory, and CVS merges the work when each developer is done.
CVS started out as a bunch of shell scripts written by
Dick Grune, posted to comp.sources.unix
in the volume 6
release of December, 1986. While no actual code from
these shell scripts is present in the current version
of CVS much of the CVS conflict resolution algorithms
come from them.
In April, 1989, Brian Berliner designed and coded CVS. Jeff Polk later helped Brian with the design of the CVS module and vendor branch support.
You can get CVS via anonymous ftp from a number of sites, for instance prep.ai.mit.edu in `pub/gnu'.
There is a mailing list, known as info-cvs
,
devoted to CVS. To subscribe or
unsubscribe
send a message to
[email protected]
. Please be
specific about your email address. As of May 1996,
subscription requests are handled by a busy human
being, so you cannot expect to be added or removed
immediately. The usenet group
comp.software.config-mgmt
is also a suitable
place for CVS discussions (along with other
configuration management systems).
CVS can do a lot of things for you, but it does not try to be everything for everyone.
VPATH
in `Makefile's, etc.), you can
arrange your disk usage however you like.
But you have to remember that any such system is
a lot of work to construct and maintain. CVS does
not address the issues involved.
Of course, you should place the tools created to
support such a build system (scripts, `Makefile's,
etc) under CVS.
Figuring out what files need to be rebuilt when
something changes is, again, something to be handled
outside the scope of CVS. One traditional
approach is to use make
for building, and use
some automated tool for generating the depencies which
make
uses.
diff3
) command.
CVS does not claim to help at all in figuring out
non-textual or distributed conflicts in program logic.
For example: Say you change the arguments to function
X
defined in file `A'. At the same time,
someone edits file `B', adding new calls to
function X
using the old arguments. You are
outside the realm of CVS's competence.
Acquire the habit of reading specs and talking to your
peers.
cvs commit
operation, CVS then forgets that those files were
checked in together, and the fact that they have the
same log message is the only thing tying them
together. Keeping a GNU style `ChangeLog'
can help somewhat.
Another aspect of change control, in some systems, is
the ability to keep track of the status of each
change. Some changes have been written by a developer,
others have been reviewed by a second developer, and so
on. Generally, the way to do this with CVS is to
generate a diff (using cvs diff
or diff
)
and email it to someone who can then apply it using the
patch
utility. This is very flexible, but
depends on mechanisms outside CVS to make sure
nothing falls through the cracks.
commitinfo
file. I haven't
heard a lot about projects trying to do that or whether
there are subtle gotchas, however.
CVS stores all files in a centralized repository (see section The Repository).
The repository contains directories and files, in an arbitrary tree. The modules feature can be used to group together a set of directories or files into a single entity (see section The modules file). A typical usage is to define one module per project.
Each version of a file has a unique revision number. Revision numbers look like `1.1', `1.2', `1.3.2.2' or even `1.3.2.2.4.5'. A revision number always has an even number of period-separated decimal integers. By default revision 1.1 is the first revision of a file. Each successive revision is given a new number by increasing the rightmost number by one. The following figure displays a few revisions, with newer revisions to the right.
+-----+ +-----+ +-----+ +-----+ +-----+ ! 1.1 !----! 1.2 !----! 1.3 !----! 1.4 !----! 1.5 ! +-----+ +-----+ +-----+ +-----+ +-----+
CVS is not limited to linear development. The revision tree can be split into branches, where each branch is a self-maintained line of development. Changes made on one branch can easily be moved back to the main trunk.
Each branch has a branch number, consisting of an odd number of period-separated decimal integers. The branch number is created by appending an integer to the revision number where the corresponding branch forked off. Having branch numbers allows more than one branch to be forked off from a certain revision.
All revisions on a branch have revision numbers formed by appending an ordinal number to the branch number. The following figure illustrates branching with an example.
+-------------+ Branch 1.2.2.3.2 -> ! 1.2.2.3.2.1 ! / +-------------+ / / +---------+ +---------+ +---------+ +---------+ Branch 1.2.2 -> _! 1.2.2.1 !----! 1.2.2.2 !----! 1.2.2.3 !----! 1.2.2.4 ! / +---------+ +---------+ +---------+ +---------+ / / +-----+ +-----+ +-----+ +-----+ +-----+ ! 1.1 !----! 1.2 !----! 1.3 !----! 1.4 !----! 1.5 ! <- The main trunk +-----+ +-----+ +-----+ +-----+ +-----+ ! ! ! +---------+ +---------+ +---------+ Branch 1.2.4 -> +---! 1.2.4.1 !----! 1.2.4.2 !----! 1.2.4.3 ! +---------+ +---------+ +---------+
The exact details of how the branch number is constructed is not something you normally need to be concerned about, but here is how it works: When CVS creates a branch number it picks the first unused even integer, starting with 2. So when you want to create a branch from revision 6.4 it will be numbered 6.4.2. All branch numbers ending in a zero (such as 6.4.0) are used internally by CVS (see section Magic branch numbers). The branch 1.1.1 has a special meaning. See section Tracking third-party sources.
A file can have several versions, as described above. Likewise, a software product can have several versions. A software product is often given a version number such as `4.1.1'.
Versions in the first sense are called revisions in this document, and versions in the second sense are called releases. To avoid confusion, the word version is almost never used in this document.
This section describes a typical work-session using CVS. It assumes that a repository is set up (see section The Repository).
Suppose you are working on a simple compiler. The source consists of a handful of C files and a `Makefile'. The compiler is called `tc' (Trivial Compiler), and the repository is set up so that there is a module called `tc'.
The first thing you must do is to get your own working copy of the
source for `tc'. For this, you use the checkout
command:
$ cvs checkout tc
This will create a new directory called `tc' and populate it with the source files.
$ cd tc $ ls CVS Makefile backend.c driver.c frontend.c parser.c
The `CVS' directory is used internally by CVS. Normally, you should not modify or remove any of the files in it.
You start your favorite editor, hack away at `backend.c', and a couple of hours later you have added an optimization pass to the compiler. A note to RCS and SCCS users: There is no need to lock the files that you want to edit. See section Multiple developers for an explanation.
When you have checked that the compiler is still compilable you decide to make a new version of `backend.c'.
$ cvs commit backend.c
CVS starts an editor, to allow you to enter a log message. You type in "Added an optimization pass.", save the temporary file, and exit the editor.
The environment variable $CVSEDITOR
determines
which editor is started. If $CVSEDITOR
is not
set, then if the environment variable $EDITOR
is
set, it will be used. If both $CVSEDITOR
and
$EDITOR
are not set then the editor defaults to
vi
. If you want to avoid the overhead of
starting an editor you can specify the log message on
the command line using the `-m' flag instead, like
this:
$ cvs commit -m "Added an optimization pass" backend.c
Before you turn to other tasks you decide to remove your working copy of tc. One acceptable way to do that is of course
$ cd .. $ rm -r tc
but a better way is to use the release
command (see section release--Indicate that a Module is no longer in use):
$ cd .. $ cvs release -d tc M driver.c ? tc You have [1] altered files in this repository. Are you sure you want to release (and delete) module `tc': n ** `release' aborted by user choice.
The release
command checks that all your modifications have been
committed. If history logging is enabled it also makes a note in the
history file. See section The history file.
When you use the `-d' flag with release
, it
also removes your working copy.
In the example above, the release
command wrote a couple of lines
of output. `? tc' means that the file `tc' is unknown to CVS.
That is nothing to worry about: `tc' is the executable compiler,
and it should not be stored in the repository. See section Ignoring files via cvsignore,
for information about how to make that warning go away.
See section release output, for a complete explanation of
all possible output from release
.
`M driver.c' is more serious. It means that the file `driver.c' has been modified since it was checked out.
The release
command always finishes by telling
you how many modified files you have in your working
copy of the sources, and then asks you for confirmation
before deleting any files or making any note in the
history file.
You decide to play it safe and answer n RET
when release
asks for confirmation.
You do not remember modifying `driver.c', so you want to see what has happened to that file.
$ cd tc $ cvs diff driver.c
This command runs diff
to compare the version of `driver.c'
that you checked out with your working copy. When you see the output
you remember that you added a command line option that enabled the
optimization pass. You check it in, and release the module.
$ cvs commit -m "Added an optimization pass" driver.c Checking in driver.c; /usr/local/cvsroot/tc/driver.c,v <-- driver.c new revision: 1.2; previous revision: 1.1 done $ cd .. $ cvs release -d tc ? tc You have [0] altered files in this repository. Are you sure you want to release (and delete) module `tc': y
The CVS repository stores a complete copy of all the files and directories which are under version control.
Normally, you never access any of the files in the repository directly. Instead, you use CVS commands to get your own copy of the files, and then work on that copy. When you've finished a set of changes, you check (or commit) them back into the repository. The repository then contains the changes which you have made, as well as recording exactly what you changed, when you changed it, and other such information.
CVS can access a repository by a variety of
means. It might be on the local computer, or it might
be on a computer across the room or across the world.
To distinguish various ways to access a repository, the
repository name can start with an access method.
For example, the access method :local:
means to
access a repository directory, so the repository
:local:/usr/local/cvsroot
means that the
repository is in `/usr/local/cvsroot' on the
computer running CVS. For information on other
access methods, see section Remote repositories.
If the access method is omitted, then if the repository
does not contain `:', then :local:
is
assumed. If it does contain `:' than either
:ext:
or :server:
is assumed. For
example, if you have a local repository in
`/usr/local/cvsroot', you can use
/usr/local/cvsroot
instead of
:local:/usr/local/cvsroot
. But if (under
Windows NT, for example) your local repository is
`c:\src\cvsroot', then you must specify the access
method, as in :local:c:\src\cvsroot
.
The repository is split in two parts. `$CVSROOT/CVSROOT' contains administrative files for CVS. The other directories contain the actual user-defined modules.
There are a couple of different ways to tell CVS
where to find the repository. You can name the
repository on the command line explicitly, with the
-d
(for "directory") option:
cvs -d /usr/local/cvsroot checkout yoyodyne/tc
Or you can set the $CVSROOT
environment
variable to an absolute path to the root of the
repository, `/usr/local/cvsroot' in this example.
To set $CVSROOT
, all csh
and tcsh
users should have this line in their `.cshrc' or
`.tcshrc' files:
setenv CVSROOT /usr/local/cvsroot
sh
and bash
users should instead have these lines in their
`.profile' or `.bashrc':
CVSROOT=/usr/local/cvsroot export CVSROOT
A repository specified with -d
will
override the $CVSROOT
environment variable.
Once you've checked a working copy out from the
repository, it will remember where its repository is
(the information is recorded in the
`CVS/Root' file in the working copy).
The -d
option and the `CVS/Root' file both
override the $CVSROOT
environment variable. If
-d
option differs from `CVS/Root', the
former is used (and specifying -d
will cause
`CVS/Root' to be updated). Of course, for proper
operation they should be two ways of referring to the
same repository.
For most purposes it isn't important how CVS stores information in the repository. In fact, the format has changed in the past, and is likely to change in the future. Since in almost all cases one accesses the repository via CVS commands; such changes need not be disruptive.
However, in some cases it may be necessary to understand how CVS stores data in the repository, for example you might need to track down CVS locks (see section Several developers simultaneously attempting to run CVS) or you might need to deal with the file permissions appropriate for the repository.
The overall structure of the repository is a directory tree corresponding to the directories in the working directory. For example, supposing the repository is in `/usr/local/cvsroot', here is a possible directory tree (showing only the directories):
/usr | +--local | | | +--cvsroot | | | | | +--CVSROOT | (administrative files) | +--gnu | | | +--diff | | (source code to GNU diff) | | | +--rcs | | (source code to RCS) | | | +--cvs | (source code to CVS) | +--yoyodyne | +--tc | | | +--man | | | +--testing | +--(other Yoyodyne software)
With the directories are history files for each file under version control. The name of the history file is the name of the corresponding file with `,v' appended to the end. Here is what the repository for the `yoyodyne/tc' directory might look like:
$CVSROOT
|
+--yoyodyne
| |
| +--tc
| | |
+--Makefile,v
+--backend.c,v
+--driver.c,v
+--frontend.c,v
+--parser.c,v
+--man
| |
| +--tc.1,v
|
+--testing
|
+--testpgm.t,v
+--test2.t,v
The history files contain, among other things, enough
information to recreate any revision of the file, a log
of all commit messages and the user-name of the person
who committed the revision. The history files are
known as RCS files, because the first program to
store files in that format was a version control system
known as RCS. For a full
description of the file format, see the man
page
rcsfile(5), distributed with RCS. This
file format has become very common--many systems other
than CVS or RCS can at least import history
files in this format.
All `,v' files are created read-only, and you should not change the permission of those files. The directories inside the repository should be writable by the persons that have permission to modify the files in each directory. This normally means that you must create a UNIX group (see group(5)) consisting of the persons that are to edit the files in a project, and set up the repository so that it is that group that owns the directory.
This means that you can only control access to files on a per-directory basis.
Note that users must also have write access to check out files, because CVS needs to create lock files (see section Several developers simultaneously attempting to run CVS).
Also note that users must have write access to the `CVSROOT/val-tags' file. CVS uses it to keep track of what tags are valid tag names (it is sometimes updated when tags are used, as well as when they are created, though).
CVS tries to set up reasonable file permissions
for new directories that are added inside the tree, but
you must fix the permissions manually when a new
directory should have different permissions than its
parent directory. If you set the CVSUMASK
environment variable that will control the file
permissions which CVS uses in creating directories
and/or files in the repository. CVSUMASK
does
not affect the file permissions in the working
directory; such files have the permissions which are
typical for newly created files, except that sometimes
CVS creates them read-only (see the sections on
watches, section Telling CVS to watch certain files; -r, section Global options; or CVSREAD, section All environment variables which affect CVS).
Since CVS was not written to be run setuid, it is unsafe to try to run it setuid. You cannot use the setuid features of RCS together with CVS.
The directory `$CVSROOT/CVSROOT' contains some administrative files. See section Reference manual for the Administrative files, for a complete description. You can use CVS without any of these files, but some commands work better when at least the `modules' file is properly set up.
The most important of these files is the `modules' file. It defines all modules in the repository. This is a sample `modules' file.
CVSROOT CVSROOT modules CVSROOT modules cvs gnu/cvs rcs gnu/rcs diff gnu/diff tc yoyodyne/tc
The `modules' file is line oriented. In its
simplest form each line contains the name of the
module, whitespace, and the directory where the module
resides. The directory is a path relative to
$CVSROOT
. The last four lines in the example
above are examples of such lines.
The line that defines the module called `modules' uses features that are not explained here. See section The modules file, for a full explanation of all the available features.
You edit the administrative files in the same way that you would edit any other module. Use `cvs checkout CVSROOT' to get a working copy, edit it, and commit your changes in the normal way.
It is possible to commit an erroneous administrative file. You can often fix the error and check in a new revision, but sometimes a particularly bad error in the administrative file makes it impossible to commit new revisions.
In some situations it is a good idea to have more than
one repository, for instance if you have two
development groups that work on separate projects
without sharing any code. All you have to do to have
several repositories is to specify the appropriate
repository, using the CVSROOT
environment
variable, the `-d' option to CVS, or (once
you have checked out a working directory) by simply
allowing CVS to use the repository that was used
to check out the working directory
(see section Telling CVS where your repository is).
The big advantage of having multiple repositories is that they can reside on different servers. The big disadvantage is that you cannot have a single CVS command recurse into directories which comes from different repositories. Generally speaking, if you are thinking of setting up several repositories on the same machine, you might want to consider using several directories within the same repository.
None of the examples in this manual show multiple repositories.
To set up a CVS repository, choose a directory with ample disk space available for the revision history of the source files. It should be accessable (directly or via a networked file system) from all machines which want to use CVS in server or local mode; the client machines need not have any access to it other than via the CVS protocol. It is not possible to use CVS to read from a repository which one only has read access to; CVS needs to be able to create lock files (see section Several developers simultaneously attempting to run CVS).
To create a repository, run the cvs init
command. It will set up an empty repository in the
CVS root specified in the usual way
(see section The Repository). For example,
cvs -d /usr/local/cvsroot init
cvs init
is careful to never overwrite any
existing files in the repository, so no harm is done if
you run cvs init
on an already set-up
repository.
cvs init
will enable history logging; if you
don't want that, remove the history file after running
cvs init
. See section The history file.
Your working copy of the sources can be on a different machine than the repository. Generally, using a remote repository is just like using a local one, except that the format of the repository name is:
:method:user@hostname:/path/to/repository
The details of exactly what needs to be set up depend on how you are connecting to the server.
If method is not specified, and the repository
name contains `:', then the default is ext
or server
, depending on your platform; both are
described in section Connecting with rsh.
CVS uses the `rsh' protocol to perform these operations, so the remote user host needs to have a `.rhosts' file which grants access to the local user.
For example, suppose you are the user `mozart' on the local machine `anklet.grunge.com', and the server machine is `chainsaw.brickyard.com'. On chainsaw, put the following line into the file `.rhosts' in `bach''s home directory:
anklet.grunge.com mozart
Then test that rsh
is working with
rsh -l bach chainsaw.brickyard.com 'echo $PATH'
Next you have to make sure that rsh
will be able
to find the server. Make sure that the path which
rsh
printed in the above example includes the
directory containing a program named cvs
which
is the server. You need to set the path in
`.bashrc', `.cshrc', etc., not `.login'
or `.profile'. Alternately, you can set the
environment variable CVS_SERVER
on the client
machine to the filename of the server you want to use,
for example `/usr/local/bin/cvs-1.6'.
There is no need to edit inetd.conf
or start a
CVS server daemon.
There are two access methods that you use in CVSROOT
for rsh. :server:
specifies an internal rsh
client, which is supported only by some CVS ports.
:ext:
specifies an external rsh program. By
default this is rsh
but you may set the
CVS_RSH
environment variable to invoke another
program which can access the remote server (for
example, remsh
on HP-UX 9 because rsh
is
something different). It must be a program which can
transmit data to and from the server without modifying
it; for example the Windows NT rsh
is not
suitable since it by default translates between CRLF
and LF. The OS/2 CVS port has a hack to pass `-b'
to rsh
to get around this, but since this could
potentially cause programs for programs other than the
standard rsh
, it may change in the future. If
you set CVS_RSH
to SSH
or some other rsh
replacement, the instructions in the rest of this
section concerning `.rhosts' and so on are likely
to be incorrect; consult the documentation for your rsh
replacement.
Continuing our example, supposing you want to access the module `foo' in the repository `/usr/local/cvsroot/', on machine `chainsaw.brickyard.com', you are ready to go:
cvs -d :ext:[email protected]:/usr/local/cvsroot checkout foo
(The `bach@' can be omitted if the username is the same on both the local and remote hosts.)
The CVS client can also connect to the server
using a password protocol. This is particularly useful
if using rsh
is not feasible (for example,
the server is behind a firewall), and Kerberos also is
not available.
To use this method, it is necessary to make some adjustments on both the server and client sides.
On the server side, the file `/etc/inetd.conf'
needs to be edited so inetd
knows to run the
command cvs pserver
when it receives a
connection on the right port. By default, the port
number is 2401; it would be different if your client
were compiled with CVS_AUTH_PORT
defined to
something else, though.
If your inetd
allows raw port numbers in
`/etc/inetd.conf', then the following (all on a
single line in `inetd.conf') should be sufficient:
2401 stream tcp nowait root /usr/local/bin/cvs cvs -b /usr/local/bin pserver
The `-b' option specifies the directory which contains the RCS binaries on the server. You could also use the `-T' option to specify a temporary directory.
If your inetd
wants a symbolic service
name instead of a raw port number, then put this in
`/etc/services':
cvspserver 2401/tcp
and put cvspserver
instead of
2401
in `inetd.conf'.
Once the above is taken care of, restart your
inetd
, or do whatever is necessary to force it
to reread its initialization files.
Because the client stores and transmits passwords in cleartext (almost--see section Security considerations with password authentication for details), a separate CVS password file may be used, so people don't compromise their regular passwords when they access the repository. This file is `$CVSROOT/CVSROOT/passwd' (see section The administrative files). Its format is similar to `/etc/passwd', except that it only has two fields, username and password. For example:
bach:ULtgRLXo7NRxs cwang:1sOp854gDF3DY
The password is encrypted according to the standard
Unix crypt()
function, so it is possible to
paste in passwords directly from regular Unix
`passwd' files.
When authenticating a password, the server first checks for the user in the CVS `passwd' file. If it finds the user, it compares against that password. If it does not find the user, or if the CVS `passwd' file does not exist, then the server tries to match the password using the system's user-lookup routine. When using the CVS `passwd' file, the server runs under as the username specified in the the third argument in the entry, or as the first argument if there is no third argument (in this way CVS allows imaginary usernames provided the CVS `passwd' file indicates corresponding valid system usernames). In any case, CVS will have no privileges which the (valid) user would not have.
Right now, the only way to put a password in the
CVS `passwd' file is to paste it there from
somewhere else. Someday, there may be a cvs
passwd
command.
Before connecting to the server, the client must log
in with the command cvs login
. Logging in
verifies a password with the server, and also records
the password for later transactions with the server.
The cvs login
command needs to know the
username, server hostname, and full repository path,
and it gets this information from the repository
argument or the CVSROOT
environment variable.
cvs login
is interactive -- it prompts for a
password:
cvs -d :pserver:[email protected]:/usr/local/cvsroot login CVS password:
The password is checked with the server; if it is
correct, the login
succeeds, else it fails,
complaining that the password was incorrect.
Once you have logged in, you can force CVS to connect directly to the server and authenticate with the stored password:
cvs -d :pserver:[email protected]:/usr/local/cvsroot checkout foo
The `:pserver:' is necessary because without it,
CVS will assume it should use rsh
to
connect with the server (see section Connecting with rsh).
(Once you have a working copy checked out and are
running CVS commands from within it, there is no
longer any need to specify the repository explicitly,
because CVS records it in the working copy's
`CVS' subdirectory.)
Passwords are stored by default in the file `$HOME/.cvspass'. Its format is human-readable, but don't edit it unless you know what you are doing. The passwords are not stored in cleartext, but are trivially encoded to protect them from "innocent" compromise (i.e., inadvertently being seen by a system administrator who happens to look at that file).
The CVS_PASSFILE
environment variable overrides
this default. If you use this variable, make sure you
set it before cvs login
is run. If you
were to set it after running cvs login
, then
later CVS commands would be unable to look up the
password for transmission to the server.
The CVS_PASSWORD
environment variable overrides
all stored passwords. If it is set, CVS
will use it for all password-authenticated
connections.
The passwords are stored on the client side in a trivial encoding of the cleartext, and transmitted in the same encoding. The encoding is done only to prevent inadvertent password compromises (i.e., a system administrator accidentally looking at the file), and will not prevent even a naive attacker from gaining the password.
The separate CVS password file (see section Setting up the server for password authentication) allows people to use a different password for repository access than for login access. On the other hand, once a user has access to the repository, she can execute programs on the server system through a variety of means. Thus, repository access implies fairly broad system access as well. It might be possible to modify CVS to prevent that, but no one has done so as of this writing. Furthermore, there may be other ways in which having access to CVS allows people to gain more general access to the system; noone has done a careful audit.
In summary, anyone who gets the password gets repository access, and some measure of general system access as well. The password is available to anyone who can sniff network packets or read a protected (i.e., user read-only) file. If you want real security, get Kerberos.
The main disadvantage of using rsh is that all the data needs to pass through additional programs, so it may be slower. So if you have kerberos installed you can connect via a direct TCP connection, authenticating with kerberos.
To do this, CVS needs to be compiled with kerberos support; when configuring CVS it tries to detect whether kerberos is present or you can use the `--with-krb4' flag to configure.
The data transmitted is not encrypted by
default. Encryption support must be compiled into both
the client and server; use the
`--enable-encryption' configure option to turn it
on. You must then use the -x
global option to
request encryption.
You need to edit inetd.conf
on the server
machine to run cvs kserver
. The client uses
port 1999 by default; if you want to use another port
specify it in the CVS_CLIENT_PORT
environment
variable on the client.
When you want to use CVS, get a ticket in the
usual way (generally kinit
); it must be a ticket
which allows you to log into the server machine. Then
you are ready to go:
cvs -d :kserver:chainsaw.brickyard.com:/user/local/cvsroot checkout foo
Previous versions of CVS would fall back to a connection via rsh; this version will not do so.
Because renaming files and moving them between directories is somewhat inconvenient, the first thing you do when you start a new project should be to think through your file organization. It is not impossible to rename or move files, but it does increase the potential for confusion and CVS does have some quirks particularly in the area of renaming directories. See section Moving and renaming files.
What to do next depends on the situation at hand.
The first step is to create the files inside the repository. This can be done in a couple of different ways.
When you begin using CVS, you will probably already have several
projects that can be
put under CVS control. In these cases the easiest way is to use the
import
command. An example is probably the easiest way to
explain how to use it. If the files you want to install in
CVS reside in `wdir', and you want them to appear in the
repository as `$CVSROOT/yoyodyne/rdir', you can do this:
$ cd wdir $ cvs import -m "Imported sources" yoyodyne/rdir yoyo start
Unless you supply a log message with the `-m' flag, CVS starts an editor and prompts for a message. The string `yoyo' is a vendor tag, and `start' is a release tag. They may fill no purpose in this context, but since CVS requires them they must be present. See section Tracking third-party sources, for more information about them.
You can now verify that it worked, and remove your original source directory.
$ cd .. $ mv dir dir.orig $ cvs checkout yoyodyne/dir # Explanation below $ ls -R yoyodyne $ rm -r dir.orig
Erasing the original sources is a good idea, to make sure that you do not accidentally edit them in dir, bypassing CVS. Of course, it would be wise to make sure that you have a backup of the sources before you remove them.
The checkout
command can either take a module
name as argument (as it has done in all previous
examples) or a path name relative to $CVSROOT
,
as it did in the example above.
It is a good idea to check that the permissions CVS sets on the directories inside `$CVSROOT' are reasonable, and that they belong to the proper groups. See section File permissions.
If some of the files you want to import are binary, you may want to use the wrappers features to specify which files are binary and which are not. See section The cvswrappers file.
If you have a project which you are maintaining with another version control system, such as RCS, you may wish to put the files from that project into CVS, and preserve the revision history of the files.
For a new project, the easiest thing to do is probably to create an empty directory structure, like this:
$ mkdir tc $ mkdir tc/man $ mkdir tc/testing
After that, you use the import
command to create
the corresponding (empty) directory structure inside
the repository:
$ cd tc $ cvs import -m "Created directory structure" yoyodyne/dir yoyo start
Then, use add
to add files (and new directories)
as they appear.
Check that the permissions CVS sets on the directories inside `$CVSROOT' are reasonable.
The next step is to define the module in the `modules' file. This is not strictly necessary, but modules can be convenient in grouping together related files and directories.
In simple cases these steps are sufficient to define a module.
$ cvs checkout CVSROOT/modules $ cd CVSROOT
tc yoyodyne/tc
$ cvs commit -m "Added the tc module." modules
$ cd .. $ cvs release -d CVSROOT
When more than one person works on a software project
things often get complicated. Often, two people try to
edit the same file simultaneously. One solution, known
as file locking or reserved checkouts, is
to allow only one person to edit each file at a time.
This is the only solution with some version control
systems, including RCS and SCCS. CVS
doesn't have a very nice implementation of reserved
checkouts (yet) but there are ways to get it working
(for example, see the cvs admin -l
command in
section admin options). It also may be possible to use
the watches features described below, together with
suitable procedures (not enforced by software), to
avoid having two people edit at the same time.
The default model with CVS is known as unreserved checkouts. In this model, developers can edit their own working copy of a file simultaneously. The first person that commits his changes has no automatic way of knowing that another has started to edit it. Others will get an error message when they try to commit the file. They must then use CVS commands to bring their working copy up to date with the repository revision. This process is almost automatic.
CVS also supports mechanisms which facilitate various kinds of communcation, without actually enforcing rules like reserved checkouts do.
The rest of this chapter describes how these various models work, and some of the issues involved in choosing between them.
Based on what operations you have performed on a
checked out file, and what operations others have
performed to that file in the repository, one can
classify a file in a number of states. The states, as
reported by the status
command, are:
add
, and not yet
committed your changes.
remove
, and not yet
committed your changes.
update
rather than
checkout
to get that newer revision.
update
command gave a conflict. You need to
resolve the conflict as described in section Conflicts example.
add
.
To help clarify the file status, status
also
reports the Working revision
which is the
revision that the file in the working directory derives
from, and the Repository revision
which is the
latest revision in the repository for the branch in
use.
For information on the options to status
, see
section status--Display status information on checked out files. For information on its Sticky tag
and Sticky date
output, see section Sticky tags.
For information on its Sticky options
output,
see the `-k' option in section update options.
When you want to update or merge a file, use the update
command. For files that are not up to date this is roughly equivalent
to a checkout
command: the newest revision of the file is
extracted from the repository and put in your working copy of the
module.
Your modifications to a file are never lost when you
use update
. If no newer revision exists,
running update
has no effect. If you have
edited the file, and a newer revision is available,
CVS will merge all changes into your working copy.
For instance, imagine that you checked out revision 1.4 and started
editing it. In the meantime someone else committed revision 1.5, and
shortly after that revision 1.6. If you run update
on the file
now, CVS will incorporate all changes between revision 1.4 and 1.6 into
your file.
If any of the changes between 1.4 and 1.6 were made too
close to any of the changes you have made, an
overlap occurs. In such cases a warning is
printed, and the resulting file includes both
versions of the lines that overlap, delimited by
special markers.
See section update--Bring work tree in sync with repository, for a complete description of the
update
command.
Suppose revision 1.4 of `driver.c' contains this:
#include <stdio.h> void main() { parse(); if (nerr == 0) gencode(); else fprintf(stderr, "No code generated.\n"); exit(nerr == 0 ? 0 : 1); }
Revision 1.6 of `driver.c' contains this:
#include <stdio.h> int main(int argc, char **argv) { parse(); if (argc != 1) { fprintf(stderr, "tc: No args expected.\n"); exit(1); } if (nerr == 0) gencode(); else fprintf(stderr, "No code generated.\n"); exit(!!nerr); }
Your working copy of `driver.c', based on revision 1.4, contains this before you run `cvs update':
#include <stdlib.h> #include <stdio.h> void main() { init_scanner(); parse(); if (nerr == 0) gencode(); else fprintf(stderr, "No code generated.\n"); exit(nerr == 0 ? EXIT_SUCCESS : EXIT_FAILURE); }
You run `cvs update':
$ cvs update driver.c RCS file: /usr/local/cvsroot/yoyodyne/tc/driver.c,v retrieving revision 1.4 retrieving revision 1.6 Merging differences between 1.4 and 1.6 into driver.c rcsmerge warning: overlaps during merge cvs update: conflicts found in driver.c C driver.c
CVS tells you that there were some conflicts. Your original working file is saved unmodified in `.#driver.c.1.4'. The new version of `driver.c' contains this:
#include <stdlib.h> #include <stdio.h> int main(int argc, char **argv) { init_scanner(); parse(); if (argc != 1) { fprintf(stderr, "tc: No args expected.\n"); exit(1); } if (nerr == 0) gencode(); else fprintf(stderr, "No code generated.\n"); <<<<<<< driver.c exit(nerr == 0 ? EXIT_SUCCESS : EXIT_FAILURE); ======= exit(!!nerr); >>>>>>> 1.6 }
Note how all non-overlapping modifications are incorporated in your working copy, and that the overlapping section is clearly marked with `<<<<<<<', `=======' and `>>>>>>>'.
You resolve the conflict by editing the file, removing the markers and the erroneous line. Suppose you end up with this file:
#include <stdlib.h> #include <stdio.h> int main(int argc, char **argv) { init_scanner(); parse(); if (argc != 1) { fprintf(stderr, "tc: No args expected.\n"); exit(1); } if (nerr == 0) gencode(); else fprintf(stderr, "No code generated.\n"); exit(nerr == 0 ? EXIT_SUCCESS : EXIT_FAILURE); }
You can now go ahead and commit this as revision 1.7.
$ cvs commit -m "Initialize scanner. Use symbolic exit values." driver.c Checking in driver.c; /usr/local/cvsroot/yoyodyne/tc/driver.c,v <-- driver.c new revision: 1.7; previous revision: 1.6 done
For your protection, CVS will refuse to check in a
file if a conflict occurred and you have not resolved
the conflict. Currently to resolve a conflict, you
must change the timestamp on the file, and must also
insure that the file contains no conflict markers. If
your file legitimately contains conflict markers (that
is, occurrences of `>>>>>>> ' at the start of a
line that don't mark a conflict), then CVS has
trouble handling this and you need to start hacking on
the CVS/Entries
file or other such workarounds.
If you use release 1.04 or later of pcl-cvs (a GNU Emacs front-end for CVS) you can use an Emacs package called emerge to help you resolve conflicts. See the documentation for pcl-cvs.
It is often useful to inform others when you commit a new revision of a file. The `-i' option of the `modules' file, or the `loginfo' file, can be used to automate this process. See section The modules file. See section Loginfo. You can use these features of CVS to, for instance, instruct CVS to mail a message to all developers, or post a message to a local newsgroup.
If several developers try to run CVS at the same time, one may get the following message:
[11:43:23] waiting for bach's lock in /usr/local/cvsroot/foo
CVS will try again every 30 seconds, and either continue with the operation or print the message again, if it still needs to wait. If a lock seems to stick around for an undue amount of time, find the person holding the lock and ask them about the cvs command they are running. If they aren't running a cvs command, look for and remove files starting with `#cvs.tfl', `#cvs.rfl', or `#cvs.wfl' from the repository.
Note that these locks are to protect CVS's internal data structures and have no relationship to the word lock in the sense used by RCS---which refers to reserved checkouts (see section Multiple developers).
Any number of people can be reading from a given repository at a time; only when someone is writing do the locks prevent other people from reading or writing.
One might hope for the following property
If someone commits some changes in one cvs command, then an update by someone else will either get all the changes, or none of them.
but CVS does not have this property. For example, given the files
a/one.c a/two.c b/three.c b/four.c
if someone runs
cvs ci a/two.c b/three.c
and someone else runs cvs update
at the same
time, the person running update
might get only
the change to `b/three.c' and not the change to
`a/two.c'.
For many groups, use of CVS in its default mode is perfectly satisfactory. Users may sometimes go to check in a modification only to find that another modification has intervened, but they deal with it and proceed with their check in. Other groups prefer to be able to know who is editing what files, so that if two people try to edit the same file they can choose to talk about who is doing what when rather than be surprised at check in time. The features in this section allow such coordination, while retaining the ability of two developers to edit the same file at the same time.
For maximum benefit developers should use cvs
edit
(not chmod
) to make files read-write to
edit them, and cvs release
(not rm
) to
discard a working directory which is no longer in use,
but CVS is not able to enforce this behavior.
To enable the watch features, you first specify that certain files are to be watched.
-l
] files ...
Specify that developers should run cvs edit
before editing files. CVS will create working
copies of files read-only, to remind developers
to run the cvs edit
command before working on
them.
If files includes the name of a directory, CVS
arranges to watch all files added to the corresponding
repository directory, and sets a default for files
added in the future; this allows the user to set
notification policies on a per-directory basis. The
contents of the directory are processed recursively,
unless the -l
option is given.
If files is omitted, it defaults to the current directory.
-l
] files ...
Do not provide notification about work on files. CVS will create working copies of files read-write.
The files and -l
arguments are processed as for cvs
watch on
.
You can tell CVS that you want to receive
notifications about various actions taken on a file.
You can do this without using cvs watch on
for
the file, but generally you will want to use cvs
watch on
, so that developers use the cvs edit
command.
-a
action] [-l
] files ...
Add the current user to the list of people to receive notification of work done on files.
The -a
option specifies what kinds of events CVS should notify
the user about. action is one of the following:
edit
cvs edit
command (described
below) to a file.
unedit
cvs unedit
command (described
below) or the cvs release
command to a file, or has deleted
the file and allowed cvs update
to recreate it.
commit
all
none
cvs edit
,
described below.)
The -a
option may appear more than once, or not at all. If
omitted, the action defaults to all
.
The files and -l
option are processed as for the
cvs watch
commands.
-a
action] [-l
] files ...
Remove a notification request established using cvs watch add
;
the arguments are the same. If the -a
option is present, only
watches for the specified actions are removed.
When the conditions exist for notification, CVS
calls the `notify' administrative file. Edit
`notify' as one edits the other administrative
files (see section The administrative files). This
file follows the usual conventions for administrative
files (see section The common syntax), where each line is a regular
expression followed by a command to execute. The
command should contain a single ocurrence of `%s'
which will be replaced by the user to notify; the rest
of the information regarding the notification will be
supplied to the command on standard input. The
standard thing to put in the notify
file is the
single line:
ALL mail %s -s \"CVS notification\"
This causes users to be notified by electronic mail.
Note that if you set this up in the straightforward way, users receive notifications on the server machine. One could of course write a `notify' script which directed notifications elsewhere, but to make this easy, CVS allows you to associate a notification address for each user. To do so create a file `users' in `CVSROOT' with a line for each user in the format user:value. Then instead of passing the name of the user to be notified to `notify', CVS will pass the value (normally an email address on some other machine).
Since a file which is being watched is checked out
read-only, you cannot simply edit it. To make it
read-write, and inform others that you are planning to
edit it, use the cvs edit
command. Some systems
call this a checkout, but CVS uses that term
for obtaining a copy of the sources (see section Getting the source), an operation which those systems call a
get or a fetch.
Prepare to edit the working files files. CVS makes the
files read-write, and notifies users who have requested
edit
notification for any of files.
The cvs edit
command accepts the same options as the
cvs watch add
command, and establishes a temporary watch for the
user on files; CVS will remove the watch when files are
unedit
ed or commit
ted. If the user does not wish to
receive notifications, she should specify -a none
.
The files and -l
option are processed as for the cvs
watch
commands.
Normally when you are done with a set of changes, you
use the cvs commit
command, which checks in your
changes and returns the watched files to their usual
read-only state. But if you instead decide to abandon
your changes, or not to make any changes, you can use
the cvs unedit
command.
-l
] files ...
Abandon work on the working files files, and revert them to the
repository versions on which they are based. CVS makes those
files read-only for which users have requested notification using
cvs watch on
. CVS notifies users who have requested unedit
notification for any of files.
The files and -l
option are processed as for the
cvs watch
commands.
If watches are not in use, the unedit
command
probably does not work, and the way to revert to the
repository version is to remove the file and then use
cvs update
to get a new copy. The meaning is
not precisely the same; removing and updating may also
bring in some changes which have been made in the
repository since the last time you updated.
When using client/server CVS, you can use the
cvs edit
and cvs unedit
commands even if
CVS is unable to succesfully communicate with the
server; the notifications will be sent upon the next
successful CVS command.
-l
] files ...
List the users currently watching changes to files. The report includes the files being watched, and the mail address of each watcher.
The files and -l
arguments are processed as for the
cvs watch
commands.
-l
] files ...
List the users currently working on files. The report includes the mail address of each user, the time when the user began working with the file, and the host and path of the working directory containing the file.
The files and -l
arguments are processed as for the
cvs watch
commands.
If you use the watch features on a repository, it creates `CVS' directories in the repository and stores the information about watches in that directory. If you attempt to use CVS 1.6 or earlier with the repository, you get an error message such as
cvs update: cannot open CVS/Entries for reading: No such file or directory
and your operation will likely be aborted. To use the
watch features, you must upgrade all copies of CVS
which use that repository in local or server mode. If
you cannot upgrade, use the watch off
and
watch remove
commands to remove all watches, and
that will restore the repository to a state which
CVS 1.6 can cope with.
Reserved and unreserved checkouts each have pros and cons. Let it be said that a lot of this is a matter of opinion or what works given different groups' working styles, but here is an attempt to briefly describe the issues. There are many ways to organize a team of developers. CVS does not try to enforce a certain organization. It is a tool that can be used in several ways.
Reserved checkouts can be very counter-productive. If two persons want to edit different parts of a file, there may be no reason to prevent either of them from doing so. Also, it is common for someone to take out a lock on a file, because they are planning to edit it, but then forget to release the lock.
People, especially people who are familiar with reserved checkouts, often wonder how often conflicts occur if unreserved checkouts are used, and how difficult they are to resolve. The experience with many groups is that they occur rarely and usually are relatively straightforward to resolve.
The rarity of serious conflicts may be surprising, until one realizes that they occur only when two developers disagree on the proper design for a given section of code; such a disagreement suggests that the team has not been communicating properly in the first place. In order to collaborate under any source management regimen, developers must agree on the general design of the system; given this agreement, overlapping changes are usually straightforward to merge.
In some cases unreserved checkouts are clearly inappropriate. If no merge tool exists for the kind of file you are managing (for example word processor files or files edited by Computer Aided Design programs), and it is not desirable to change to a program which uses a mergeable data format, then resolving conflicts is going to be unpleasant enough that you generally will be better off to simply avoid the conflicts instead, by using reserved checkouts.
The watches features described above in section Mechanisms to track who is editing files can be considered to be an intermediate model between reserved checkouts and unreserved checkouts. When you go to edit a file, it is possible to find out who else is editing it. And rather than having the system simply forbid both people editing the file, it can tell you what the situation is and let you figure out whether it is a problem in that particular case or not. Therefore, for some groups it can be considered the best of both the reserved checkout and unreserved checkout worlds.
So far, all revisions shown in this manual have been on the main trunk of the revision tree, i.e., all revision numbers have been of the form x.y. One useful feature, especially when maintaining several releases of a software product at once, is the ability to make branches on the revision tree. Tags, symbolic names for revisions, will also be introduced in this chapter.
The revision numbers live a life of their own. They need not have anything at all to do with the release numbers of your software product. Depending on how you use CVS the revision numbers might change several times between two releases. As an example, some of the source files that make up RCS 5.6 have the following revision numbers:
ci.c 5.21 co.c 5.9 ident.c 5.3 rcs.c 5.12 rcsbase.h 5.11 rcsdiff.c 5.10 rcsedit.c 5.11 rcsfcmp.c 5.9 rcsgen.c 5.10 rcslex.c 5.11 rcsmap.c 5.2 rcsutil.c 5.10
You can use the tag
command to give a symbolic name to a
certain revision of a file. You can use the `-v' flag to the
status
command to see all tags that a file has, and
which revision numbers they represent. Tag names can
contain uppercase and lowercase letters, digits,
`-', and `_'. The two tag names BASE
and HEAD
are reserved for use by CVS. It
is expected that future names which are special to
CVS will contain characters such as `%' or
`=', rather than being named analogously to
BASE
and HEAD
, to avoid conflicts with
actual tag names.
The following example shows how you can add a tag to a file. The commands must be issued inside your working copy of the module. That is, you should issue the command in the directory where `backend.c' resides.
$ cvs tag release-0-4 backend.c T backend.c $ cvs status -v backend.c =================================================================== File: backend.c Status: Up-to-date Version: 1.4 Tue Dec 1 14:39:01 1992 RCS Version: 1.4 /usr/local/cvsroot/yoyodyne/tc/backend.c,v Sticky Tag: (none) Sticky Date: (none) Sticky Options: (none) Existing Tags: release-0-4 (revision: 1.4)
There is seldom reason to tag a file in isolation. A more common use is to tag all the files that constitute a module with the same tag at strategic points in the development life-cycle, such as when a release is made.
$ cvs tag release-1-0 . cvs tag: Tagging . T Makefile T backend.c T driver.c T frontend.c T parser.c
(When you give CVS a directory as argument, it generally applies the operation to all the files in that directory, and (recursively), to any subdirectories that it may contain. See section Recursive behavior.)
The checkout
command has a flag, `-r', that lets you check out
a certain revision of a module. This flag makes it easy to
retrieve the sources that make up release 1.0 of the module `tc' at
any time in the future:
$ cvs checkout -r release-1-0 tc
This is useful, for instance, if someone claims that there is a bug in that release, but you cannot find the bug in the current working copy.
You can also check out a module as it was at any given date. See section checkout options.
When you tag more than one file with the same tag you can think about the tag as "a curve drawn through a matrix of filename vs. revision number." Say we have 5 files with the following revisions:
file1 file2 file3 file4 file5 1.1 1.1 1.1 1.1 /--1.1* <-*- TAG 1.2*- 1.2 1.2 -1.2*- 1.3 \- 1.3*- 1.3 / 1.3 1.4 \ 1.4 / 1.4 \-1.5*- 1.5 1.6
At some time in the past, the *
versions were tagged.
You can think of the tag as a handle attached to the curve
drawn through the tagged revisions. When you pull on
the handle, you get all the tagged revisions. Another
way to look at it is that you "sight" through a set of
revisions that is "flat" along the tagged revisions,
like this:
file1 file2 file3 file4 file5 1.1 1.2 1.1 1.3 _ 1.1 1.2 1.4 1.1 / 1.2*----1.3*----1.5*----1.2*----1.1 (--- <--- Look here 1.3 1.6 1.3 \_ 1.4 1.4 1.5
Suppose that release 1.0 of tc has been made. You are continuing to develop tc, planning to create release 1.1 in a couple of months. After a while your customers start to complain about a fatal bug. You check out release 1.0 (see section Tags--Symbolic revisions) and find the bug (which turns out to have a trivial fix). However, the current revision of the sources are in a state of flux and are not expected to be stable for at least another month. There is no way to make a bugfix release based on the newest sources.
The thing to do in a situation like this is to create a branch on the revision trees for all the files that make up release 1.0 of tc. You can then make modifications to the branch without disturbing the main trunk. When the modifications are finished you can select to either incorporate them on the main trunk, or leave them on the branch.
The rtag
command can be used to create a branch.
The rtag
command is much like tag
, but it
does not require that you have a working copy of the
module. See section rtag--Add a symbolic tag to a module. (You can also use the tag
command; see section tag--Add a symbolic tag to checked out versions of files).
$ cvs rtag -b -r release-1-0 release-1-0-patches tc
The `-b' flag makes rtag
create a branch
(rather than just a symbolic revision name). `-r
release-1-0' says that this branch should be rooted at the node (in
the revision tree) that corresponds to the tag
`release-1-0'. Note that the numeric revision number that matches
`release-1-0' will probably be different from file to file. The
name of the new branch is `release-1-0-patches', and the
module affected is `tc'.
To fix the problem in release 1.0, you need a working copy of the branch you just created.
$ cvs checkout -r release-1-0-patches tc $ cvs status -v driver.c backend.c =================================================================== File: driver.c Status: Up-to-date Version: 1.7 Sat Dec 5 18:25:54 1992 RCS Version: 1.7 /usr/local/cvsroot/yoyodyne/tc/driver.c,v Sticky Tag: release-1-0-patches (branch: 1.7.2) Sticky Date: (none) Sticky Options: (none) Existing Tags: release-1-0-patches (branch: 1.7.2) release-1-0 (revision: 1.7) =================================================================== File: backend.c Status: Up-to-date Version: 1.4 Tue Dec 1 14:39:01 1992 RCS Version: 1.4 /usr/local/cvsroot/yoyodyne/tc/backend.c,v Sticky Tag: release-1-0-patches (branch: 1.4.2) Sticky Date: (none) Sticky Options: (none) Existing Tags: release-1-0-patches (branch: 1.4.2) release-1-0 (revision: 1.4) release-0-4 (revision: 1.4)
As the output from the status
command shows the branch
number is created by adding a digit at the tail of the revision number
it is based on. (If `release-1-0' corresponds to revision 1.4, the
branch's revision number will be 1.4.2. For obscure reasons CVS always
gives branches even numbers, starting at 2.
See section Revision numbers).
The `-r release-1-0-patches' flag that was given
to checkout
in the previous example
is sticky, that is, it will apply to subsequent commands
in this directory. If you commit any modifications, they are
committed on the branch. You can later merge the modifications into
the main trunk. See section Merging.
You can use the status
command to see what
sticky tags or dates are set:
$ vi driver.c # Fix the bugs $ cvs commit -m "Fixed initialization bug" driver.c Checking in driver.c; /usr/local/cvsroot/yoyodyne/tc/driver.c,v <-- driver.c new revision: 1.7.2.1; previous revision: 1.7 done $ cvs status -v driver.c =================================================================== File: driver.c Status: Up-to-date Version: 1.7.2.1 Sat Dec 5 19:35:03 1992 RCS Version: 1.7.2.1 /usr/local/cvsroot/yoyodyne/tc/driver.c,v Sticky Tag: release-1-0-patches (branch: 1.7.2) Sticky Date: (none) Sticky Options: (none) Existing Tags: release-1-0-patches (branch: 1.7.2) release-1-0 (revision: 1.7)
The sticky tags will remain on your working files until you delete them with `cvs update -A'. The `-A' option retrieves the version of the file from the head of the trunk, and forgets any sticky tags, dates, or options.
Sticky tags are not just for branches. For example,
suppose that you want to avoid updating your working
directory, to isolate yourself from possibly
destabilizing changes other people are making. You
can, of course, just refrain from running cvs
update
. But if you want to avoid updating only a
portion of a larger tree, then sticky tags can help.
If you check out a certain revision (such as 1.4) it
will become sticky. Subsequent cvs update
will
not retrieve the latest revision until you reset the
tag with cvs update -A
. Likewise, use of the
`-D' option to update
or checkout
sets a sticky date, which, similarly, causes that
date to be used for future retrievals.
Many times you will want to retrieve an old version of
a file without setting a sticky tag. The way to do
that is with the `-p' option to checkout
or
update
, which sends the contents of the file to
standard output. For example, suppose you have a file
named `file1' which existed as revision 1.1, and
you then removed it (thus adding a dead revision 1.2).
Now suppose you want to add it again, with the same
contents it had previously. Here is how to do it:
$ cvs update -p -r 1.1 file1 >file1 =================================================================== Checking out file1 RCS: /tmp/cvs-sanity/cvsroot/first-dir/Attic/file1,v VERS: 1.1 *************** $ cvs add file1 cvs add: re-adding file file1 (in place of dead revision 1.2) cvs add: use 'cvs commit' to add this file permanently $ cvs commit -m test Checking in file1; /tmp/cvs-sanity/cvsroot/first-dir/file1,v <-- file1 new revision: 1.3; previous revision: 1.2 done $
You can include the changes made between any two revisions into your working copy, by merging. You can then commit that revision, and thus effectively copy the changes onto another branch.
You can merge changes made on a branch into your working copy by giving
the `-j branch' flag to the update
command. With one
`-j branch' option it merges the changes made between the
point where the branch forked and newest revision on that branch (into
your working copy).
+-----+ +-----+ +-----+ +-----+ ! 1.1 !----! 1.2 !----! 1.3 !----! 1.4 ! <- The main trunk +-----+ +-----+ +-----+ +-----+ ! ! ! +---------+ +---------+ Branch R1fix -> +---! 1.2.2.1 !----! 1.2.2.2 ! +---------+ +---------+
The branch 1.2.2 has been given the tag (symbolic name) `R1fix'. The following example assumes that the module `mod' contains only one file, `m.c'.
$ cvs checkout mod # Retrieve the latest revision, 1.4 $ cvs update -j R1fix m.c # Merge all changes made on the branch, # i.e. the changes between revision 1.2 # and 1.2.2.2, into your working copy # of the file. $ cvs commit -m "Included R1fix" # Create revision 1.5.
A conflict can result from a merge operation. If that happens, you should resolve it before committing the new revision. See section Conflicts example.
The checkout
command also supports the `-j branch' flag. The
same effect as above could be achieved with this:
$ cvs checkout -j R1fix mod $ cvs commit -m "Included R1fix"
Continuing our example, the revision tree now looks like this:
+-----+ +-----+ +-----+ +-----+ +-----+ ! 1.1 !----! 1.2 !----! 1.3 !----! 1.4 !----! 1.5 ! <- The main trunk +-----+ +-----+ +-----+ +-----+ +-----+ ! * ! * ! +---------+ +---------+ Branch R1fix -> +---! 1.2.2.1 !----! 1.2.2.2 ! +---------+ +---------+
where the starred line represents the merge from the `R1fix' branch to the main trunk, as just discussed.
Now suppose that development continues on the `R1fix' branch:
+-----+ +-----+ +-----+ +-----+ +-----+ ! 1.1 !----! 1.2 !----! 1.3 !----! 1.4 !----! 1.5 ! <- The main trunk +-----+ +-----+ +-----+ +-----+ +-----+ ! * ! * ! +---------+ +---------+ +---------+ Branch R1fix -> +---! 1.2.2.1 !----! 1.2.2.2 !----! 1.2.2.3 ! +---------+ +---------+ +---------+
and then you want to merge those new changes onto the
main trunk. If you just use the cvs update -j
R1fix m.c
command again, CVS will attempt to
merge again the changes which you have already merged,
which can have undesirable side effects.
So instead you need to specify that you only want to merge the changes on the branch which have not yet been merged into the trunk. To do that you specify two `-j' options, and CVS merges the changes from the first revision to the second revision. For example, in this case the simplest way would be
cvs update -j 1.2.2.2 -j R1fix m.c # Merge changes from 1.2.2.2 to the # head of the R1fix branch
The problem with this is that you need to specify the 1.2.2.2 revision manually. A slightly better approach might be to use the date the last merge was done:
cvs update -j R1fix:yesterday -j R1fix m.c
Better yet, tag the R1fix branch after every merge into the trunk, and then use that tag for subsequent merges:
cvs update -j merged_from_R1fix_to_trunk -j R1fix m.c
With two `-j revision' flags, the update
(and checkout
) command can merge the differences
between any two revisions into your working file.
$ cvs update -j 1.5 -j 1.3 backend.c
will remove all changes made between revision 1.3 and 1.5. Note the order of the revisions!
If you try to use this option when operating on multiple files, remember that the numeric revisions will probably be very different between the various files that make up a module. You almost always use symbolic tags rather than revision numbers when operating on multiple files.
If the changes which you are merging involve removing
or adding some files, update -j
will reflect
such additions or removals.
For example:
cvs update -A touch a b c cvs add a b c ; cvs ci -m "added" a b c cvs tag -b branchtag cvs update -r branchtag touch d ; cvs add d rm a ; cvs rm a cvs ci -m "added d, removed a" cvs update -A cvs update -jbranchtag
Almost all of the subcommands of CVS work recursively when you specify a directory as an argument. For instance, consider this directory structure:
$HOME
|
+--tc
| |
+--CVS
| (internal CVS files)
+--Makefile
+--backend.c
+--driver.c
+--frontend.c
+--parser.c
+--man
| |
| +--CVS
| | (internal CVS files)
| +--tc.1
|
+--testing
|
+--CVS
| (internal CVS files)
+--testpgm.t
+--test2.t
If `tc' is the current working directory, the following is true:
tc
module
If no arguments are given to update
it will
update all files in the current working directory and
all its subdirectories. In other words, `.' is a
default argument to update
. This is also true
for most of the CVS subcommands, not only the
update
command.
The recursive behavior of the CVS subcommands can be turned off with the `-l' option.
$ cvs update -l # Don't update files in subdirectories
To add a new file to a directory, follow these steps.
You can also use the add
command to add a new
directory.
Unlike most other commands, the add
command is
not recursive. You cannot even type `cvs add
foo/bar'! Instead, you have to
$ cd foo $ cvs add bar
-k
kflag] [-m
message] files ...
Schedule files to be added to the repository.
The files or directories specified with add
must
already exist in the current directory. To add a whole
new directory hierarchy to the source repository (for
example, files received from a third-party vendor), use
the import
command instead. See section import--Import sources into CVS, using vendor branches.
The added files are not placed in the source repository
until you use commit
to make the change
permanent. Doing an add
on a file that was
removed with the remove
command will undo the
effect of the remove
, unless a commit
command intervened. See section Removing files from a module, for an
example.
The `-k' option specifies the default way that this file will be checked out; for more information see section Substitution modes.
The `-m' option specifies a description for the
file. This description appears in the history log (if
it is enabled, see section The history file). It will also be
saved in the version history inside the repository when
the file is committed. The log
command displays
this description. The description can be changed using
`admin -t'. See section admin--Administration front end for rcs. If you omit the
`-m description' flag, an empty string will
be used. You will not be prompted for a description.
For example, the following commands add the file `backend.c' to the repository:
$ cvs add backend.c $ cvs commit -m "Early version. Not yet compilable." backend.c
When you add a file it is added only on the branch which you are working on (see section Branches). You can later merge the additions to another branch if you want (see section Merging can add or remove files).
Modules change. New files are added, and old files disappear. Still, you want to be able to retrieve an exact copy of old releases of the module.
Here is what you can do to remove a file from a module, but remain able to retrieve old revisions:
status
or update
command. If you remove
the file without committing your changes, you will of
course not be able to retrieve the file as it was
immediately before you deleted it.
rm
.
When you commit the removal of the file, CVS
records the fact that the file no longer exists. It is
possible for a file to exist on only some branches and
not on others, or to re-add another file with the same
name later. CVS will correctly create or not create
the file, based on the `-r' and `-D' options
specified to checkout
or update
.
-lR
] files ...
Schedule file(s) to be removed from the repository (files which have not already been removed from the working directory are not processed). This command does not actually remove the file from the repository until you commit the removal. The `-R' option (the default) specifies that it will recurse into subdirectories; `-l' specifies that it will not.
Here is an example of removing several files:
$ cd test $ rm ?.c $ cvs remove cvs remove: Removing . cvs remove: scheduling a.c for removal cvs remove: scheduling b.c for removal cvs remove: use 'cvs commit' to remove these files permanently $ cvs ci -m "Removed unneeded files" cvs commit: Examining . cvs commit: Committing .
If you change your mind you can easily resurrect the
file before you commit it, using the add
command.
$ ls CVS ja.h oj.c $ rm oj.c $ cvs remove oj.c cvs remove: scheduling oj.c for removal cvs remove: use 'cvs commit' to remove this file permanently $ cvs add oj.c U oj.c cvs add: oj.c, version 1.1.1.1, resurrected
If you realize your mistake before you run the
remove
command you can use update
to
resurrect the file:
$ rm oj.c $ cvs update oj.c cvs update: warning: oj.c was lost U oj.c
When you remove a file it is added only on the branch which you are working on (see section Branches). You can later merge the additions to another branch if you want (see section Merging can add or remove files).
If you modify a program to better fit your site, you probably want to include your modifications when the next release of the program arrives. CVS can help you with this task.
In the terminology used in CVS, the supplier of the program is called a vendor. The unmodified distribution from the vendor is checked in on its own branch, the vendor branch. CVS reserves branch 1.1.1 for this use.
When you modify the source and commit it, your revision will end up on the main trunk. When a new release is made by the vendor, you commit it on the vendor branch and copy the modifications onto the main trunk.
Use the import
command to create and update
the vendor branch. After a successful import
the vendor branch is made the `head' revision, so
anyone that checks out a copy of the file gets that
revision. When a local modification is committed it is
placed on the main trunk, and made the `head'
revision.
Use the import
command to check in the sources
for the first time. When you use the import
command to track third-party sources, the vendor
tag and release tags are useful. The
vendor tag is a symbolic name for the branch
(which is always 1.1.1, unless you use the `-b
branch' flag---See section import options). The
release tags are symbolic names for a particular
release, such as `FSF_0_04'.
Suppose you use wdiff
(a variant of diff
that ignores changes that only involve whitespace), and
are going to make private modifications that you want
to be able to use even when new releases are made in
the future. You start by importing the source to your
repository:
$ tar xfz wdiff-0.04.tar.gz $ cd wdiff-0.04 $ cvs import -m "Import of FSF v. 0.04" fsf/wdiff FSF_DIST WDIFF_0_04
The vendor tag is named `FSF_DIST' in the above example, and the only release tag assigned is `WDIFF_0_04'.
When a new release of the source arrives, you import it into the
repository with the same import
command that you used to set up
the repository in the first place. The only difference is that you
specify a different release tag this time.
$ tar xfz wdiff-0.05.tar.gz $ cd wdiff-0.05 $ cvs import -m "Import of FSF v. 0.05" fsf/wdiff FSF_DIST WDIFF_0_05
For files that have not been modified locally, the newly created
revision becomes the head revision. If you have made local
changes, import
will warn you that you must merge the changes
into the main trunk, and tell you to use `checkout -j' to do so.
$ cvs checkout -jFSF_DIST:yesterday -jFSF_DIST wdiff
The above command will check out the latest revision of `wdiff', merging the changes made on the vendor branch `FSF_DIST' since yesterday into the working copy. If any conflicts arise during the merge they should be resolved in the normal way (see section Conflicts example). Then, the modified files may be committed.
Using a date, as suggested above, assumes that you do not import more than one release of a product per day. If you do, you can always use something like this instead:
$ cvs checkout -jWDIFF_0_04 -jWDIFF_0_05 wdiff
In this case, the two above commands are equivalent.
Use the `-k' wrapper option to tell import which files are binary. See section The cvswrappers file.
Moving files to a different directory or renaming them is not difficult, but some of the ways in which this works may be non-obvious. (Moving or renaming a directory is even harder. See section Moving and renaming directories).
The examples below assume that the file old is renamed to new.
The normal way to move a file is to copy old to new, and then issue the normal CVS commands to remove old from the repository, and add new to it. (Both old and new could contain relative paths, for example `foo/bar.c').
$ mv old new $ cvs remove old $ cvs add new $ cvs commit -m "Renamed old to new" old new
This is the simplest way to move a file, it is not
error-prone, and it preserves the history of what was
done. Note that to access the history of the file you
must specify the old or the new name, depending on what
portion of the history you are accessing. For example,
cvs log old
will give the log up until the
time of the rename.
When new is committed its revision numbers will start at 1.0 again, so if that bothers you, use the `-r rev' option to commit (see section commit options)
This method is more dangerous, since it involves moving files inside the repository. Read this entire section before trying it out!
$ cd $CVSROOT/module $ mv old,v new,v
Advantages:
Disadvantages:
This way also involves direct modifications to the repository. It is safe, but not without drawbacks.
# Copy the RCS file inside the repository $ cd $CVSROOT/module $ cp old,v new,v # Remove the old file $ cd ~/module $ rm old $ cvs remove old $ cvs commit old # Remove all tags from new $ cvs update new $ cvs log new # Remember the non-branch tag names $ cvs tag -d tag1 new $ cvs tag -d tag2 new ...
By removing the tags you will be able to check out old revisions of the module.
Advantages:
Disadvantages:
If you want to be able to retrieve old versions of the module, you must move each file in the directory with the CVS commands. See section The Normal way to Rename. The old, empty directory will remain inside the repository, but it will not appear in your workspace when you check out the module in the future.
If you really want to rename or delete a directory, you can do it like this:
$ cd $CVSROOT/module $ mv old-dir new-dir
If someone had a working copy of the module the CVS commands will cease to work for him, until he removes the directory that disappeared inside the repository.
It is almost always better to move the files in the directory instead of moving the directory. If you move the directory you are unlikely to be able to retrieve old releases correctly, since they probably depend on the name of the directories.
Once you have used CVS to store a version control history--what files have changed when, how, and by whom, there are a variety of mechanisms for looking through the history.
Whenever you commit a file you specify a log message.
To look through the log messages which have been
specified for every revision which has been committed,
use the cvs log
command (see section log--Print out log information for files).
You can use the history file (see section The history file) to
log various CVS actions. To retrieve the
information from the history file, use the cvs
history
command (see section history--Show status of files and users).
You can customize CVS to log various kinds of
actions, in whatever manner you choose. These
mechanisms operate by executing a script at various
times. The script might append a message to a file
listing the information and the programmer who created
it, or send mail to a group of developers, or, perhaps,
post a message to a particular newsgroup. To log
commits, use the `loginfo' file (see section Loginfo).
To log commits, checkouts, exports, and tags,
respectively, you can also use the `-i',
`-o', `-e', and `-t' options in the
modules file. For a more flexible way of giving
notifications to various users, which requires less in
the way of keeping centralized scripts up to date, use
the cvs watch add
command (see section Telling CVS to notify you); this command is useful even if you are not
using cvs watch on
.
The `taginfo' file defines programs to execute
when someone executes a tag
or rtag
command. The `taginfo' file has the standard form
for administrative files (see section Reference manual for the Administrative files), where each line is a regular expression
followed by a command to execute. The arguments passed
to the command are, in order, the tagname,
operation (add
for tag
,
mov
for tag -F
, and del
for
tag -d
), repository, and any remaining are
pairs of filename revision. A non-zero
exit of the filter program will cause the tag to be
aborted.
-lf
] [-r rev
|-D date
] files ...
For each file in files, print the head revision of the trunk, together with information on the last modification for each line. For example:
$ cvs annotate ssfile Annotations for ssfile *************** 1.1 (mary 27-Mar-96): ssfile line 1 1.2 (joe 28-Mar-96): ssfile line 2
The file `ssfile' currently contains two lines.
The ssfile line 1
line was checked in by
mary
on March 27. Then, on March 28, joe
added a line ssfile line 2
, without modifying
the ssfile line 1
line. This report doesn't
tell you anything about lines which have been deleted
or replaced; you need to use cvs diff
for that
(see section diff--Run diffs between revisions).
These standard options are available with
annotate
(see section Common command options, for a complete
description of them):
-D date
-f
-l
-r tag
As long as you edit source files inside your working copy of a module you can always find out the state of your files via `cvs status' and `cvs log'. But as soon as you export the files from your development environment it becomes harder to identify which revisions they are.
RCS uses a mechanism known as keyword
substitution (or keyword expansion) to help
identifying the files. Embedded strings of the form
$keyword$
and
$keyword:...$
in a file are replaced
with strings of the form
$keyword:value$
whenever you obtain
a new revision of the file.
This is a list of the keywords that RCS currently (in release 5.6.0.1) supports:
$Author$
$Date$
$Header$
$Id$
$Header$
, except that the RCS
filename is without a path.
$Name$
$Locker$
$Log$
$Log:...$
.
Each new line is prefixed with a comment leader
which RCS guesses from the file name extension.
It can be changed with cvs admin -c
.
See section admin options. This keyword is useful for
accumulating a complete change log in a source file,
but for several reasons it can be problematic.
See section Problems with the $Log$ keyword..
$RCSfile$
$Revision$
$Source$
$State$
cvs admin -s
---See section admin options.
To include a keyword string you simply include the
relevant text string, such as $Id$
, inside the
file, and commit the file. CVS will automatically
expand the string as part of the commit operation.
It is common to embed $
Id$ string in the
C source code. This example shows the first few lines
of a typical file, after keyword substitution has been
performed:
static char *rcsid="$Id: samp.c,v 1.5 1993/10/19 14:57:32 ceder Exp $";
/* The following lines will prevent gcc
version 2.x
from issuing an "unused variable" warning. */
#if __GNUC__ == 2
#define USE(var) static void * use_##var = (&use_##var, (void *) &var)
USE (rcsid);
#endif
Even though a clever optimizing compiler could remove
the unused variable rcsid
, most compilers tend
to include the string in the binary. Some compilers
have a #pragma
directive to include literal text
in the binary.
The ident
command (which is part of the RCS
package) can be used to extract keywords and their
values from a file. This can be handy for text files,
but it is even more useful for extracting keywords from
binary files.
$ ident samp.c samp.c: $Id: samp.c,v 1.5 1993/10/19 14:57:32 ceder Exp $ $ gcc samp.c $ ident a.out a.out: $Id: samp.c,v 1.5 1993/10/19 14:57:32 ceder Exp $
SCCS is another popular revision control system.
It has a command, what
, which is very similar to
ident
and used for the same purpose. Many sites
without RCS have SCCS. Since what
looks for the character sequence @(#)
it is
easy to include keywords that are detected by either
command. Simply prefix the RCS keyword with the
magic SCCS phrase, like this:
static char *id="@(#) $Id: ab.c,v 1.5 1993/10/19 14:57:32 ceder Exp $";
Keyword substitution has its disadvantages. Sometimes you might want the literal text string `$'Author$ to appear inside a file without RCS interpreting it as a keyword and expanding it into something like `$'Author: ceder $.
There is unfortunately no way to selectively turn off keyword substitution. You can use `-ko' (see section Substitution modes) to turn off keyword substitution entirely.
In many cases you can avoid using RCS keywords in
the source, even though they appear in the final
product. For example, the source for this manual
contains `$@asis{}Author$' whenever the text
`$'Author$ should appear. In nroff
and troff
you can embed the null-character
\&
inside the keyword for a similar effect.
Each file has a stored default substitution mode, and
each working directory copy of a file also has a
substitution mode. The former is set by the `-k'
option to cvs add
and cvs admin
; the
latter is set by the -k or -A options to cvs
checkout
or cvs update
. cvs diff
also
has a `-k' option. For some examples,
See section Handling binary files.
The modes available are:
$
Revision: 5.7 $ for the Revision
keyword.
Revision
keyword, generate the string $
Revision$
instead of $
Revision: 5.7 $. This option
is useful to ignore differences due to keyword
substitution when comparing different revisions of a
file.
Revision
keyword, generate the string
$
Revision: 1.1 $ instead of
$
Revision: 5.7 $ if that is how the
string appeared when the file was checked in.
Revision
keyword, generate the string
5.7
instead of $
Revision: 5.7 $.
This can help generate files in programming languages
where it is hard to strip keyword delimiters like
$
Revision: $ from a string. However,
further keyword substitution cannot be performed once
the keyword names are removed, so this option should be
used with care.
One often would like to use `-kv' with cvs
export
---see section export--Export sources from CVS, similar to checkout. But be aware that doesn't
handle an export containing binary files correctly.
The $
Log$ keyword is somewhat
controversial. As long as you are working on your
development system the information is easily accessible
even if you do not use the $
Log$
keyword--just do a cvs log
. Once you export
the file the history information might be useless
anyhow.
A more serious concern is that RCS is not good at
handling $
Log$ entries when a branch is
merged onto the main trunk. Conflicts often result
from the merging operation.
People also tend to "fix" the log entries in the file
(correcting spelling mistakes and maybe even factual
errors). If that is done the information from
cvs log
will not be consistent with the
information inside the file. This may or may not be a
problem in real life.
It has been suggested that the $
Log$
keyword should be inserted last in the file, and
not in the files header, if it is to be used at all.
That way the long list of change messages will not
interfere with everyday source file browsing.
There are two issues with using CVS to store binary files. The first is that CVS by default convert line endings between the canonical form in which they are stored in the repository (linefeed only), and the form appropriate to the operating system in use on the client (for example, carriage return followed by line feed for Windows NT).
The second is that a binary file might happen to contain data which looks like a keyword (see section Keyword substitution), so keyword expansion must be turned off.
The `-kb' option available with some CVS commands insures that neither line ending conversion nor keyword expansion will be done. If you are using an old version of RCS without this option, and you are using an operating system, such as unix, which terminates lines with linefeeds only, you can use `-ko' instead; if you are on another operating system, upgrade to a version of RCS, such as 5.7 or later, which supports `-kb'.
Here is an example of how you can create a new file using the `-kb' flag:
$ echo '$Id$' > kotest $ cvs add -kb -m"A test file" kotest $ cvs ci -m"First checkin; contains a keyword" kotest
If a file accidentally gets added without `-kb',
one can use the cvs admin
command to recover.
For example:
$ echo '$Id$' > kotest $ cvs add -m"A test file" kotest $ cvs ci -m"First checkin; contains a keyword" kotest $ cvs admin -kb kotest $ cvs update -A kotest $ cvs commit -m "make it binary" kotest # For non-unix systems
When you check in the file `kotest' the keywords
are expanded. (Try the above example, and do a
cat kotest
after every command). The cvs
admin -kb
command sets the default keyword
substitution method for this file, but it does not
alter the working copy of the file that you have. The
easiest way to get the unexpanded version of
`kotest' is cvs update -A
. If you need to
cope with line endings (that is, you are using a
CVS client on a non-unix system), then you need to
check in a new copy of the file, as shown by the
cvs commit
command above.
However, in using cvs admin -k
to change the
keyword expansion, be aware that the keyword expansion
mode is not version controlled. This means that, for
example, that if you have a text file in old releases,
and a binary file with the same name in new releases,
CVS provides no way to check out the file in text
or binary mode depending on what version you are
checking out. There is no good workaround for this
problem.
You can also set a default for whether cvs add
and cvs import
treat a file as binary based on
its name; for example you could say that files who
names end in `.exe' are binary. See section The cvswrappers file.
If you have read this far, you probably have a pretty good grasp on what CVS can do for you. This chapter talks a little about things that you still have to decide.
If you are doing development on your own using CVS you could probably skip this chapter. The questions this chapter takes up become more important when more than one person is working in a repository.
Your group should decide which policy to use regarding commits. Several policies are possible, and as your experience with CVS grows you will probably find out what works for you.
If you commit files too quickly you might commit files that do not even compile. If your partner updates his working sources to include your buggy file, he will be unable to compile the code. On the other hand, other persons will not be able to benefit from the improvements you make to the code if you commit very seldom, and conflicts will probably be more common.
It is common to only commit files after making sure that they can be compiled. Some sites require that the files pass a test suite. Policies like this can be enforced using the commitinfo file (see section Commitinfo), but you should think twice before you enforce such a convention. By making the development environment too controlled it might become too regimented and thus counter-productive to the real goal, which is to get software written.
This appendix describes how to invoke CVS, and describes in detail those subcommands of CVS which are not fully described elsewhere. To look up a particular subcommand, see section Index.
The overall format of all CVS commands is:
cvs [ cvs_options ] cvs_command [ command_options ] [ command_args ]
cvs
cvs_options
cvs_command
command_options
command_args
There is unfortunately some confusion between
cvs_options
and command_options
.
`-l', when given as a cvs_option
, only
affects some of the commands. When it is given as a
command_option
is has a different meaning, and
is accepted by more commands. In other words, do not
take the above categorization too seriously. Look at
the documentation instead.
There are some command_options
that are used so
often that you might have set up an alias or some other
means to make sure you always specify that option. One
example (the one that drove the implementation of the
.cvsrc support, actually) is that many people find the
default output of the `diff' command to be very
hard to read, and that either context diffs or unidiffs
are much easier to understand.
The `~/.cvsrc' file is a way that you can add
default options to cvs_commands
within cvs,
instead of relying on aliases or other shell scripts.
The format of the `~/.cvsrc' file is simple. The
file is searched for a line that begins with the same
name as the cvs_command
being executed. If a
match is found, then the remainder of the line is split
up (at whitespace characters) into separate options and
added to the command arguments before any
options from the command line.
If a command has two names (e.g., checkout
and
co
), the official name, not necessarily the one
used on the command line, will be used to match against
the file. So if this is the contents of the user's
`~/.cvsrc' file:
log -N diff -u update -P co -P
the command `cvs checkout foo' would have the `-P' option added to the arguments, as well as `cvs co foo'.
With the example file above, the output from `cvs
diff foobar' will be in unidiff format. `cvs diff
-c foobar' will provide context diffs, as usual.
Getting "old" format diffs would be slightly more
complicated, because diff
doesn't have an option
to specify use of the "old" format, so you would need
`cvs -f diff foobar'.
In place of the command name you can use cvs
to
specify global options (see section Global options). For
example the following line in `.cvsrc'
cvs -z6
causes CVS to use compression level 6
The available `cvs_options' (that are given to the left of `cvs_command') are:
-b bindir
$RCSBIN
environment
variable and any precompiled directory. This parameter should be
specified as an absolute pathname.
-T tempdir
$TMPDIR
environment
variable and any precompiled directory. This parameter should be
specified as an absolute pathname.
-d cvs_root_directory
$CVSROOT
environment variable. See section The Repository.
-e editor
$CVSEDITOR
and $EDITOR
environment variables.
-f
-H
-l
-n
-Q
-q
-r
$CVSREAD
environment variable is set
(see section All environment variables which affect CVS). The default is to
make working files writable, unless watches are on
(see section Mechanisms to track who is editing files).
-s variable=value
-t
-v
-w
$CVSREAD
environment variable.
Files are created read-write by default, unless $CVSREAD
is
set or `-r' is given.
-x
-z gzip-level
This section describes the `command_options' that are available across several CVS commands. These options are always given to the right of `cvs_command'. Not all commands support all of these options; each option is only supported for commands where it makes sense. However, when a command has one of these options you can almost always count on the same behavior of the option as in other commands. (Other command options, which are listed with the individual commands, may have different behavior from one CVS command to the other).
Warning: the `history' command is an exception; it supports many options that conflict even with these standard options.
-D date_spec
1 month ago 2 hours ago 400000 seconds ago last year last Monday yesterday a fortnight ago 3/31/92 10:00:07 PST January 23, 1987 10:05pm 22:00 GMT`-D' is available with the
checkout
,
diff
, export
, history
,
rdiff
, rtag
, and update
commands.
(The history
command uses this option in a
slightly different way; see section history options). Note
that when specifying a date like `3/31/92' it is
month/day/year
. So
`1/4/96' is January 4, not March 1.
Remember to quote the argument to the `-D'
flag so that your shell doesn't interpret spaces as
argument separators. A command using the `-D'
flag can look like this:
$ cvs diff -D "1 hour ago" cvs.texinfo
-f
checkout
,
export
, rdiff
, rtag
, and update
.
Warning: The commit
command also has a
`-f' option, but it has a different behavior for
that command. See section commit options.
-H
-k kflag
checkout
or update
commands,
CVS associates your selected kflag with the
file, and continues to use it with future update
commands on the same file until you specify otherwise.
The `-k' option is available with the add
,
checkout
, diff
and
update
commands.
-l
checkout
,
commit
, diff
, export
, log
,
remove
, rdiff
, rtag
,
status
, tag
, and update
.
-m message
add
,
commit
and import
.
-n
checkout
, commit
, export
,
and rtag
commands.
-P
checkout
, or update
. Normally, an empty directory
(one that is void of revision-controlled files) is left alone.
Specifying `-P' will cause these directories to be silently
removed from your checked-out sources. This does not remove the
directory from the repository, only from your checked out copy.
Note that this option is implied by the `-r' or `-D'
options of checkout
and export
.
-p
checkout
and update
commands.
-W
import
,
and update
.
-r tag
tag
or rtag
command, two special tags are
always available: `HEAD' refers to the most recent version
available in the repository, and `BASE' refers to the
revision you last checked out into the current working directory.
The tag specification is sticky when you use this
with checkout
or update
to make your own
copy of a file: CVS remembers the tag and continues to use it on
future update commands, until you specify otherwise (for more information
on sticky tags/dates, see section Sticky tags). The
tag can be either a symbolic or numeric tag.
See section Tags--Symbolic revisions.
Specifying the `-q' global option along with the
`-r' command option is often useful, to suppress
the warning messages when the RCS history file
does not contain the specified tag.
Warning: this is not the same as the overall `cvs -r' option,
which you can specify to the left of a cvs command!
`-r' is available with the checkout
, commit
,
diff
, history
, export
, rdiff
,
rtag
, and update
commands.
This is the CVS interface to assorted administrative RCS
facilities, documented in rcs(1). admin
simply passes
all its options and arguments to the rcs
command; it does
no filtering or other processing. This command does work
recursively, however, so extreme care should be used.
If there is a group whose name matches a compiled in
value which defaults to cvsadmin
, only members
of that group can use cvs admin
. To disallow
cvs admin
for all users, create a group with no
users in it.
Not all valid rcs
options are useful together
with CVS. Some even makes it impossible to use
CVS until you undo the effect!
This description of the available options is based on the `rcs(1)' man page, but modified to suit readers that are more interrested in CVS than RCS.
-Aoldfile
-alogins
-b[rev]
-cstring
$
Log$ (see section Keyword substitution).
This is useful for programming languages without
multi-line comments. RCS initially guesses the
value of the comment leader from the file name
extension when the file is first committed.
-e[logins]
-I
-i
-ksubst
cvs update
, cvs export
, or cvs
checkout
overrides this default.
-l[rev]
-L
-mrev:msg
-Nname[:[rev]]
-nname[:[rev]]
-orange
-q
-sstate[:rev]
dead
state for its own purposes; to
take a file to or from the dead
state use
commands like cvs remove
and cvs add
, not
cvs admin -s
.
-t[file]
-t-string
-U
-u[rev]
.
by itself.
-Vn
-xsuffixes
First, an example of how not to use the
admin
command. It is included to stress the
fact that this command can be quite dangerous unless
you know exactly what you are doing.
The `-o' option can be used to outdate old revisions from the history file. If you are short on disc this option might help you. But think twice before using it--there is no way short of restoring the latest backup to undo this command!
The next line is an example of a command that you would not like to execute.
$ cvs admin -o:R_1_02 .
The above command will delete all revisions up to, and including, the revision that corresponds to the tag R_1_02. But beware! If there are files that have not changed between R_1_02 and R_1_03 the file will have the same numerical revision number assigned to the tags R_1_02 and R_1_03. So not only will it be impossible to retrieve R_1_02; R_1_03 will also have to be restored from the tapes!
If you use the $
Log$ keyword and you do
not agree with the guess for comment leader that
CVS has done, you can enforce your will with
cvs admin -c
. This might be suitable for
nroff
source:
$ cvs admin -c'.\" ' *.man $ rm *.man $ cvs update
The two last steps are to make sure that you get the versions with correct comment leaders in your working files.
Make a working directory containing copies of the
source files specified by modules. You must execute
checkout
before using most of the other CVS
commands, since most of them operate on your working
directory.
The modules part of the command are either symbolic names for some collection of source directories and files, or paths to directories or files in the repository. The symbolic names are defined in the `modules' file. See section The modules file.
Depending on the modules you specify, checkout
may
recursively create directories and populate them with
the appropriate source files. You can then edit these
source files at any time (regardless of whether other
software developers are editing their own copies of the
sources); update them to include new changes applied by
others to the source repository; or commit your work as
a permanent change to the source repository.
Note that checkout
is used to create
directories. The top-level directory created is always
added to the directory where checkout
is
invoked, and usually has the same name as the specified
module. In the case of a module alias, the created
sub-directory may have a different name, but you can be
sure that it will be a sub-directory, and that
checkout
will show the relative path leading to
each file as it is extracted into your private work
area (unless you specify the `-Q' global option).
The files created by checkout
are created
read-write, unless the `-r' option to CVS
(see section Global options) is specified, the
CVSREAD
environment variable is specified
(see section All environment variables which affect CVS), or a watch is in
effect for that file (see section Mechanisms to track who is editing files).
Running checkout
on a directory that was already
built by a prior checkout
is also permitted, and
has the same effect as specifying the `-d' option
to the update
command, that is, any new
directories that have been created in the repository
will appear in your work area. See section update--Bring work tree in sync with repository.
For the output produced by the checkout
command
see section update output.
These standard options are supported by checkout
(see section Common command options, for a complete description of
them):
-D date
-f
-k kflag
status
command can be viewed
to see the sticky options. See section status--Display status information on checked out files.
-l
-n
-P
-p
-r tag
In addition to those, you can use these special command
options with checkout
:
-A
-c
-d dir
-j tag
-N
-s
Get a copy of the module `tc':
$ cvs checkout tc
Get a copy of the module `tc' as it looked one day ago:
$ cvs checkout -D yesterday tc
Warning: The `-f file' option will probably be renamed to `-F file', and `-f' will be given a new behavior in future releases of CVS.
Use commit
when you want to incorporate changes
from your working source files into the source
repository.
If you don't specify particular files to commit, all of
the files in your working current directory are
examined. commit
is careful to change in the
repository only those files that you have really
changed. By default (or if you explicitly specify the
`-R' option), files in subdirectories are also
examined and committed if they have changed; you can
use the `-l' option to limit commit
to the
current directory only.
commit
verifies that the selected files are up
to date with the current revisions in the source
repository; it will notify you, and exit without
committing, if any of the specified files must be made
current first with update
(see section update--Bring work tree in sync with repository).
commit
does not call the update
command
for you, but rather leaves that for you to do when the
time is right.
When all is well, an editor is invoked to allow you to
enter a log message that will be written to one or more
logging programs (see section The modules file, and see section Loginfo)
and placed in the RCS history file inside the
repository. This log message can be retrieved with the
log
command; See section log--Print out log information for files. You can specify the
log message on the command line with the `-m
message' option, and thus avoid the editor invocation,
or use the `-f file' option to specify
that the argument file contains the log message.
These standard options are supported by commit
(see section Common command options, for a complete description of
them):
-l
-n
-R
-r revision
commit
also supports these options:
-F file
-f
$ cvs commit -f file $ cvs commit -r 1.8 file
-f file
-m message
When you make a major release of your product, you might want the revision numbers to track your major release number. You should normally not care about the revision numbers, but this is a thing that many people want to do, and it can be done without doing any harm.
To bring all your files up to the RCS revision 3.0 (including those that haven't changed), you might do:
$ cvs commit -r 3.0
Note that it is generally a bad idea to try to make the
RCS revision number equal to the current release number
of your product. You should think of the revision
number as an internal number that the CVS package
maintains, and that you generally never need to care
much about. Using the tag
and rtag
commands you can give symbolic names to the releases
instead. See section tag--Add a symbolic tag to checked out versions of files and See section rtag--Add a symbolic tag to a module.
Note that the number you specify with `-r' must be larger than any existing revision number. That is, if revision 3.0 exists, you cannot `cvs commit -r 1.3'.
You can commit to a branch revision (one that has an
even number of dots) with the `-r' option. To
create a branch revision, use the `-b' option
of the rtag
or tag
commands (see section tag--Add a symbolic tag to checked out versions of files
or see section rtag--Add a symbolic tag to a module). Then, either checkout
or
update
can be used to base your sources on the
newly created branch. From that point on, all
commit
changes made within these working sources
will be automatically added to a branch revision,
thereby not disturbing main-line development in any
way. For example, if you had to create a patch to the
1.2 version of the product, even though the 2.0 version
is already under development, you might do:
$ cvs rtag -b -r FCS1_2 FCS1_2_Patch product_module $ cvs checkout -r FCS1_2_Patch product_module $ cd product_module [[ hack away ]] $ cvs commit
This works automatically since the `-r' option is sticky.
Say you have been working on some extremely experimental software, based on whatever revision you happened to checkout last week. If others in your group would like to work on this software with you, but without disturbing main-line development, you could commit your change to a new branch. Others can then checkout your experimental stuff and utilize the full benefit of CVS conflict resolution. The scenario might look like:
[[ hacked sources are present ]] $ cvs tag -b EXPR1 $ cvs update -r EXPR1 $ cvs commit
The update
command will make the `-r
EXPR1' option sticky on all files. Note that your
changes to the files will never be removed by the
update
command. The commit
will
automatically commit to the correct branch, because the
`-r' is sticky. You could also do like this:
[[ hacked sources are present ]] $ cvs tag -b EXPR1 $ cvs commit -r EXPR1
but then, only those files that were changed by you will have the `-r EXPR1' sticky flag. If you hack away, and commit without specifying the `-r EXPR1' flag, some files may accidentally end up on the main trunk.
To work with you on the experimental change, others would simply do
$ cvs checkout -r EXPR1 whatever_module
The diff
command is used to compare different
revisions of files. The default action is to compare
your working files with the revisions they were based
on, and report any differences that are found.
If any file names are given, only those files are compared. If any directories are given, all files under them will be compared.
The exit status will be 0 if no differences were found, 1 if some differences were found, and 2 if any error occurred.
These standard options are supported by diff
(see section Common command options, for a complete description of
them):
-D date
rcsdiff
(which in turn passes it on
to diff
. GNU diff uses `-D' as a way to
put cpp
-style `#define' statements around the output
differences. There is no way short of testing to
figure out how CVS was configured. In the default
configuration CVS will use the `-D date' option.
-k kflag
-l
-R
-r tag
Any other options that are found are passed through to
rcsdiff
, which in turn passes them to
diff
. The exact meaning of the options depends
on which diff
you are using. The long options
introduced in GNU diff 2.0 are not yet supported in
CVS. See the documentation for your diff
to see
which options are supported.
The following line produces a Unidiff (`-u' flag) between revision 1.14 and 1.19 of `backend.c'. Due to the `-kk' flag no keywords are substituted, so differences that only depend on keyword substitution are ignored.
$ cvs diff -kk -u -r 1.14 -r 1.19 backend.c
Suppose the experimental branch EXPR1 was based on a set of files tagged RELEASE_1_0. To see what has happened on that branch, the following can be used:
$ cvs diff -r RELEASE_1_0 -r EXPR1
A command like this can be used to produce a context diff between two releases:
$ cvs diff -c -r RELEASE_1_0 -r RELEASE_1_1 > diffs
If you are maintaining ChangeLogs, a command like the following just before you commit your changes may help you write the ChangeLog entry. All local modifications that have not yet been committed will be printed.
$ cvs diff -u | less
This command is a variant of checkout
; use it
when you want a copy of the source for module without
the CVS administrative directories. For example, you
might use export
to prepare source for shipment
off-site. This command requires that you specify a
date or tag (with `-D' or `-r'), so that you
can count on reproducing the source you ship to others.
One often would like to use `-kv' with cvs
export
. This causes any RCS keywords to be
expanded such that an import done at some other site
will not lose the keyword revision information. But be
aware that doesn't handle an export containing binary
files correctly. Also be aware that after having used
`-kv', one can no longer use the ident
command (which is part of the RCS suite--see
ident(1)) which looks for RCS keyword strings. If
you want to be able to use ident
you must not
use `-kv'.
These standard options are supported by export
(see section Common command options, for a complete description of
them):
-D date
-f
-l
-n
-R
-r tag
In addition, these options (that are common to
checkout
and export
) are also supported:
-d dir
-k subst
-N
CVS can keep a history file that tracks each use of the
checkout
, commit
, rtag
,
update
, and release
commands. You can
use history
to display this information in
various formats.
Logging must be enabled by creating the file `$CVSROOT/CVSROOT/history'.
Warning: history
uses `-f', `-l',
`-n', and `-p' in ways that conflict with the
normal use inside CVS (see section Common command options).
Several options (shown above as `-report') control what kind of report is generated:
-c
-e
-m module
-o
-T
-x type
F
O
T
C
G
U
W
A
M
R
The options shown as `-flags' constrain or expand the report without requiring option arguments:
-a
history
).
-l
-w
history
is
executing.
The options shown as `-options args' constrain the report based on an argument:
-b str
-D date
-p repository
-r rev
-t tag
-u name
Use import
to incorporate an entire source
distribution from an outside source (e.g., a source
vendor) into your source repository directory. You can
use this command both for initial creation of a
repository, and for wholesale updates to the module
from the outside source. See section Tracking third-party sources, for
a discussion on this subject.
The repository argument gives a directory name (or a path to a directory) under the CVS root directory for repositories; if the directory did not exist, import creates it.
When you use import for updates to source that has been modified in your source repository (since a prior import), it will notify you of any files that conflict in the two branches of development; use `checkout -j' to reconcile the differences, as import instructs you to do.
If CVS decides a file should be ignored (see section Ignoring files via cvsignore), it does not import it and prints `I ' followed by the filename (see section import output, for a complete description of the output).
If the file `$CVSROOT/CVSROOT/cvswrappers' exists, any file whose names match the specifications in that file will be treated as packages and the appropriate filtering will be performed on the file/directory before being imported, See section The cvswrappers file.
The outside source is saved in a first-level RCS branch, by default 1.1.1. Updates are leaves of this branch; for example, files from the first imported collection of source will be revision 1.1.1.1, then files from the first imported update will be revision 1.1.1.2, and so on.
At least three arguments are required.
repository is needed to identify the collection
of source. vendortag is a tag for the entire
branch (e.g., for 1.1.1). You must also specify at
least one releasetag to identify the files at
the leaves created each time you execute import
.
This standard option is supported by import
(see section Common command options, for a complete description):
-m message
There are three additional special options.
-b branch
-k subst
-I name
-W spec
import
keeps you informed of its progress by printing a line
for each file, preceded by one character indicating the status of the file:
U file
N file
C file
I file
L file
See section Tracking third-party sources, and See section Creating a directory tree from a number of files.
Display log information for files. log
used to
call the RCS utility rlog
. Although this
is no longer true in the current sources, this history
determines the format of the output and the options,
which are not quite in the style of the other CVS
commands.
The output includes the location of the RCS file, the head revision (the latest revision on the trunk), all symbolic names (tags) and some other things. For each revision, the revision number, the author, the number of lines added/deleted and the log message are printed. All times are displayed in Coordinated Universal Time (UTC). (Other parts of CVS print times in the local timezone).
By default, log
prints all information that is
available. All other options restrict the output.
-b
-d dates
d1<d2
d2>d1
<d
d>
d<
>d
d
-h
-l
-N
-R
-rrevisions
rev1:rev2
:rev
rev:
branch
branch1:branch2
branch.
-s states
-t
-wlogins
log
prints the intersection of the revisions
selected with the options `-d', `-s', and
`-w', intersected with the union of the revisions
selected by `-b' and `-r'.
Contributed examples are gratefully accepted.
Builds a Larry Wall format patch(1) file between two releases, that can be fed directly into the patch program to bring an old release up-to-date with the new release. (This is one of the few CVS commands that operates directly from the repository, and doesn't require a prior checkout.) The diff output is sent to the standard output device.
You can specify (using the standard `-r' and `-D' options) any combination of one or two revisions or dates. If only one revision or date is specified, the patch file reflects differences between that revision or date and the current head revisions in the RCS file.
Note that if the software release affected is contained in more than one directory, then it may be necessary to specify the `-p' option to the patch command when patching the old sources, so that patch is able to find the files that are located in other directories.
These standard options are supported by rdiff
(see section Common command options, for a complete description of
them):
-D date
-f
-l
-r tag
In addition to the above, these options are available:
-c
-s
-t
-u
patch
program can't handle the unidiff
format, so if you plan to post this patch to the net
you should probably not use `-u'.
-V vn
Suppose you receive mail from [email protected] asking for an update from release 1.2 to 1.4 of the tc compiler. You have no such patches on hand, but with CVS that can easily be fixed with a command such as this:
$ cvs rdiff -c -r FOO1_2 -r FOO1_4 tc | \ $$ Mail -s 'The patches you asked for' [email protected]
Suppose you have made release 1.3, and forked a branch called `R_1_3fix' for bugfixes. `R_1_3_1' corresponds to release 1.3.1, which was made some time ago. Now, you want to see how much development has been done on the branch. This command can be used:
$ cvs patch -s -r R_1_3_1 -r R_1_3fix module-name cvs rdiff: Diffing module-name File ChangeLog,v changed from revision 1.52.2.5 to 1.52.2.6 File foo.c,v changed from revision 1.52.2.3 to 1.52.2.4 File bar.h,v changed from revision 1.29.2.1 to 1.2
This command is meant to safely cancel the effect of `cvs checkout'. Since CVS doesn't lock files, it isn't strictly necessary to use this command. You can always simply delete your working directory, if you like; but you risk losing changes you may have forgotten, and you leave no trace in the CVS history file (see section The history file) that you've abandoned your checkout.
Use `cvs release' to avoid these problems. This command checks that no uncommitted changes are present; that you are executing it from immediately above a CVS working directory; and that the repository recorded for your files is the same as the repository defined in the module database.
If all these conditions are true, `cvs release' leaves a record of its execution (attesting to your intentionally abandoning your checkout) in the CVS history log.
The release
command supports one command option:
-d
release
command deletes
all directories and files recursively. This
has the very serious side-effect that any directory
that you have created inside your checked-out sources,
and not added to the repository (using the add
command; see section Adding files to a directory) will be silently deleted--even
if it is non-empty!
Before release
releases your sources it will
print a one-line message for any file that is not
up-to-date.
Warning: Any new directories that you have
created, but not added to the CVS directory hierarchy
with the add
command (see section Adding files to a directory) will be
silently ignored (and deleted, if `-d' is
specified), even if they contain files.
U file
A file
R file
M file
? file
Release the module, and delete your local working copy of the files.
$ cd .. # You must stand immediately above the # sources when you issue `cvs release'. $ cvs release -d tc You have [0] altered files in this repository. Are you sure you want to release (and delete) module `tc': y $
You can use this command to assign symbolic tags to
particular, explicitly specified source revisions in
the repository. rtag
works directly on the
repository contents (and requires no prior checkout).
Use tag
instead (see section tag--Add a symbolic tag to checked out versions of files), to base the
selection of revisions on the contents of your
working directory.
If you attempt to use a tag name that already exists, CVS will complain and not overwrite that tag. Use the `-F' option to force the new tag value.
These standard options are supported by rtag
(see section Common command options, for a complete description of
them):
-D date
-f
-F
-l
-n
-R
-r tag
In addition to the above common options, these options are available:
-a
rtag
look in the
`Attic' (see section Removing files from a module) for removed files
that contain the specified tag. The tag is removed from
these files, which makes it convenient to re-use a
symbolic tag as development continues (and files get
removed from the up-coming distribution).
-b
-d
Display a brief report on the current status of files
with respect to the source repository. For information
on the basic output see section File status. For
information on the Sticky tag
and Sticky
date
output, see section Sticky tags. For information
on the Sticky options
output, see the `-k'
option in section update options.
You can also use this command to determine the
potential impact of a `cvs update' on your working
source directory--but remember that things might
change in the repository before you run update
.
These standard options are supported by status
(see section Common command options, for a complete description of
them):
-l
-R
There is one additional option:
-v
Use this command to assign symbolic tags to the nearest
repository versions to your working sources. The tags
are applied immediately to the repository, as with
rtag
, but the versions are supplied implicitly by the
CVS records of your working files' history rather than
applied explicitly.
One use for tags is to record a snapshot of the current sources when the software freeze date of a project arrives. As bugs are fixed after the freeze date, only those changed sources that are to be part of the release need be re-tagged.
The symbolic tags are meant to permanently record which
revisions of which files were used in creating a
software distribution. The checkout
and
update
commands allow you to extract an exact
copy of a tagged release at any time in the future,
regardless of whether files have been changed, added,
or removed since the release was tagged.
This command can also be used to delete a symbolic tag, or to create a branch. See the options section below.
If you attempt to use a tag name that already exists, CVS will complain and not overwrite that tag. Use the `-F' option to force the new tag value.
These standard options are supported by tag
(see section Common command options, for a complete description of
them):
-F
-l
-R
Two special options are available:
-b
-c
-d
After you've run checkout to create your private copy
of source from the common repository, other developers
will continue changing the central source. From time
to time, when it is convenient in your development
process, you can use the update
command from
within your working directory to reconcile your work
with any revisions applied to the source repository
since your last checkout or update.
These standard options are available with update
(see section Common command options, for a complete description of
them):
-D date
-f
-k kflag
status
command can be viewed
to see the sticky options. See section status--Display status information on checked out files.
-l
-P
-p
-R
-r tag
These special options are also available with
update
.
-A
-d
update
acts only on directories and files that
were already enrolled in your working directory.
This is useful for updating directories that were
created in the repository since the initial checkout;
but it has an unfortunate side effect. If you
deliberately avoided certain directories in the
repository when you created your working directory
(either through use of a module name or by listing
explicitly the files and directories you wanted on the
command line), then updating with `-d' will create
those directories, which may not be what you want.
-I name
-Wspec
-jrevision
update
and checkout
keep you informed of
its progress by printing a line for each file, preceded
by one character indicating the status of the file:
U file
A file
commit
on the file. This is a
reminder to you that the file needs to be committed.
R file
commit
on the file. This is a
reminder to you that the file needs to be committed.
M file
update
) will be made. The exact
name of that file is printed while update
runs.
C file
? file
The following line will display all files which are not up-to-date without actually change anything in your working directory. It can be used to check what has been going on with the project.
$ cvs -n -q update
Inside the repository, in the directory `$CVSROOT/CVSROOT', there are a number of supportive files for CVS. You can use CVS in a limited fashion without any of them, but if they are set up properly they can help make life easier. For a discussion of how to edit them, See section The administrative files.
The most important of these files is the `modules' file, which defines the modules inside the repository.
The `modules' file records your definitions of
names for collections of source code. CVS will
use these definitions if you use CVS to update the
modules file (use normal commands like add
,
commit
, etc).
The `modules' file may contain blank lines and comments (lines beginning with `#') as well as module definitions. Long lines can be continued on the next line by specifying a backslash (`\') as the last character on the line.
A module definition is a single line of the `modules' file, in either of two formats. In both cases, mname represents the symbolic module name, and the remainder of the line is its definition.
mname -a aliases...
checkout
creates all intermediate directories in the working
directory, just as if the path had been specified
explicitly in the CVS arguments.
mname [ options ] dir [ files... ] [ &module... ]
$CVSROOT
) to a
directory of source in the source repository. In this
case, on checkout, a single directory called
mname is created as a working directory; no
intermediate directory levels are used by default, even
if dir was a path involving several directory
levels.
By explicitly specifying files in the module definition
after dir, you can select particular files from
directory dir. The sample definition for
`modules' is an example of a module defined with a
single file from a particular directory. Here is
another example:
m4test unsupported/gnu/m4 foreach.m4 forloop.m4With this definition, executing `cvs checkout m4test' will create a single working directory `m4test' containing the two files listed, which both come from a common directory several levels deep in the CVS source repository. A module definition can refer to other modules by including `&module' in its definition.
checkout
creates a subdirectory for each such
module, in your working directory.
-d name
-e prog
-i prog
-o prog
-s status
-t prog
rtag
. prog runs
with two arguments: the module name and the symbolic
tag specified to rtag
. There is no way to
specify a program to run when tag
is executed.
-u prog
Wrappers allow you to set a hook which transforms files on their way in and out of CVS. Most or all of the wrappers features do not work with client/server CVS.
The file `cvswrappers' defines the script that will be
run on a file when its name matches a regular
expresion. There are two scripts that can be run on a
file or directory. One script is executed on the file/directory
before being checked into the repository (this is denoted
with the -t
flag) and the other when the file is
checked out of the repository (this is denoted with the
-f
flag)
The `cvswrappers' also has a `-m' option to
specify the merge methodology that should be used when
the file is updated. MERGE
means the usual
CVS behavior: try to merge the files (this
generally will not work for binary files). COPY
means that cvs update
will merely copy one
version over the other, and require the user using
mechanisms outside CVS, to insert any necessary
changes.
The `-m' wrapper option only affects behavior when
merging is done on update; it does not affect how files
are stored. See See section Handling binary files, for more on
binary files.
The basic format of the file `cvswrappers' is:
wildcard [option value][option value]... where option is one of -f from cvs filter value: path to filter -t to cvs filter value: path to filter -m update methodology value: MERGE or COPY -k keyword expansion value: expansion mode and value is a single-quote delimited value.
*.nib -f 'unwrap %s' -t 'wrap %s %s' -m 'COPY' *.c -t 'indent %s %s'
The above example of a `cvswrappers' file
states that all files/directories that end with a .nib
should be filtered with the `wrap' program before
checking the file into the repository. The file should
be filtered though the `unwrap' program when the
file is checked out of the repository. The
`cvswrappers' file also states that a COPY
methodology should be used when updating the files in
the repository (that is no merging should be performed).
The last example line says that all files that end with
a *.c
should be filtered with `indent'
before being checked into the repository. Unlike the previous
example no filtering of the *.c
file is done when
it is checked out of the repository.
The -t
filter is called with two arguments,
the first is the name of the file/directory to filter
and the second is the pathname to where the resulting
filtered file should be placed.
The -f
filter is called with one argument,
which is the name of the file to filter from. The end
result of this filter will be a file in the users directory
that they can work on as they normally would.
For another example, the following command imports a directory, treating files whose name ends in `.exe' as binary:
cvs import -I ! -W "*.exe -k 'b'" first-dir vendortag reltag
The `-i' flag in the `modules' file can be used to run a certain program whenever files are committed (see section The modules file). The files described in this section provide other, more flexible, ways to run programs whenever something is committed.
There are three kind of programs that can be run on commit. They are specified in files in the repository, as described below. The following table summarizes the file names and the purpose of the corresponding programs.
The four files `commitinfo', `loginfo', `rcsinfo' and `editinfo' all have a common format. The purpose of the files are described later on. The common syntax is described here.
Each line contains the following:
Blank lines are ignored. Lines that start with the character `#' are treated as comments. Long lines unfortunately can not be broken in two parts in any way.
The first regular expression that matches the current directory name in the repository is used. The rest of the line is used as a file name or command-line as appropriate.
The `commitinfo' file defines programs to execute whenever `cvs commit' is about to execute. These programs are used for pre-commit checking to verify that the modified, added and removed files are really ready to be committed. This could be used, for instance, to verify that the changed files conform to to your site's standards for coding practice.
As mentioned earlier, each line in the `commitinfo' file consists of a regular expression and a command-line template. The template can include a program name and any number of arguments you wish to supply to it. The full path to the current source repository is appended to the template, followed by the file names of any files involved in the commit (added, removed, and modified files).
The first line with a regular expression matching the relative path to the module will be used. If the command returns a non-zero exit status the commit will be aborted.
If the repository name does not match any of the regular expressions in this file, the `DEFAULT' line is used, if it is specified.
All occurances of the name `ALL' appearing as a regular expression are used in addition to the first matching regular expression or the name `DEFAULT'.
Note: when CVS is accessing a remote repository, `commitinfo' will be run on the remote (i.e., server) side, not the client side (see section Remote repositories).
If you want to make sure that all log messages look the same way, you can use the `editinfo' file to specify a program that is used to edit the log message. This program could be a custom-made editor that always enforces a certain style of the log message, or maybe a simple shell script that calls an editor, and checks that the entered message contains the required fields.
If no matching line is found in the `editinfo'
file, the editor specified in the environment variable
$CVSEDITOR
is used instead. If that variable is
not set, then the environment variable $EDITOR
is used instead. If that variable is not
set a precompiled default, normally vi
, will be
used.
The `editinfo' file is often most useful together with the `rcsinfo' file, which can be used to specify a log message template.
Each line in the `editinfo' file consists of a regular expression and a command-line template. The template must include a program name, and can include any number of arguments. The full path to the current log message template file is appended to the template.
One thing that should be noted is that the `ALL' keyword is not supported. If more than one matching line is found, the first one is used. This can be useful for specifying a default edit script in a module, and then overriding it in a subdirectory.
If the repository name does not match any of the regular expressions in this file, the `DEFAULT' line is used, if it is specified.
If the edit script exits with a non-zero exit status, the commit is aborted.
Note: when CVS is accessing a remote repository,
or when the `-m' or `-F' options to cvs
commit
are used, `editinfo' will not be consulted.
There is no good workaround for this.
The following is a little silly example of a `editinfo' file, together with the corresponding `rcsinfo' file, the log message template and an editor script. We begin with the log message template. We want to always record a bug-id number on the first line of the log message. The rest of log message is free text. The following template is found in the file `/usr/cvssupport/tc.template'.
BugId:
The script `/usr/cvssupport/bugid.edit' is used to edit the log message.
#!/bin/sh # # bugid.edit filename # # Call $EDITOR on FILENAME, and verify that the # resulting file contains a valid bugid on the first # line. if [ "x$EDITOR" = "x" ]; then EDITOR=vi; fi if [ "x$CVSEDITOR" = "x" ]; then CVSEDITOR=$EDITOR; fi $CVSEDITOR $1 until head -1|grep '^BugId:[ ]*[0-9][0-9]*$' < $1 do echo -n "No BugId found. Edit again? ([y]/n)" read ans case ${ans} in n*) exit 1;; esac $CVSEDITOR $1 done
The `editinfo' file contains this line:
^tc /usr/cvssupport/bugid.edit
The `rcsinfo' file contains this line:
^tc /usr/cvssupport/tc.template
The `loginfo' file is used to control where
`cvs commit' log information is sent. The first
entry on a line is a regular expression which is tested
against the directory that the change is being made to,
relative to the $CVSROOT
. If a match is found, then
the remainder of the line is a filter program that
should expect log information on its standard input.
The filter program may use one and only one % modifier (a la printf). If `%s' is specified in the filter program, a brief title is included (enclosed in single quotes) showing the modified file names.
If the repository name does not match any of the regular expressions in this file, the `DEFAULT' line is used, if it is specified.
All occurances of the name `ALL' appearing as a regular expression are used in addition to the first matching regular expression or `DEFAULT'.
The first matching regular expression is used.
See section The commit support files, for a description of the syntax of the `loginfo' file.
Note: when CVS is accessing a remote repository, `loginfo' will be run on the remote (i.e., server) side, not the client side (see section Remote repositories).
The following `loginfo' file, together with the tiny shell-script below, appends all log messages to the file `$CVSROOT/CVSROOT/commitlog', and any commits to the administrative files (inside the `CVSROOT' directory) are also logged in `/usr/adm/cvsroot-log'.
ALL /usr/local/bin/cvs-log $CVSROOT/CVSROOT/commitlog ^CVSROOT /usr/local/bin/cvs-log /usr/adm/cvsroot-log
The shell-script `/usr/local/bin/cvs-log' looks like this:
#!/bin/sh (echo "-----------------------------------------------------------------"; echo -n $USER" "; date; echo; sed '1s+'${CVSROOT}'++') >> $1
It is often useful to maintain a directory tree which contains files which correspond to the latest version in the repository. For example, other developers might want to refer to the latest sources without having to check them out, or you might be maintaining a web site with CVS and want every checkin to cause the files used by the web server to be updated.
The way to do this is by having loginfo invoke
cvs update
. Doing so in the naive way will
cause a problem with locks, so the cvs update
must be run in the background.
Here is an example (this should all be on one line):
^cyclic-pages (date; cat; (sleep 2; cd /u/www/local-docs; cvs -q update -d) &) >> $CVSROOT/CVSROOT/updatelog 2>&1
This will cause checkins to repository directories
starting with cyclic-pages
to update the checked
out tree in `/u/www/local-docs'.
The `rcsinfo' file can be used to specify a form to edit when filling out the commit log. The `rcsinfo' file has a syntax similar to the `editinfo', `commitinfo' and `loginfo' files. See section The common syntax. Unlike the other files the second part is not a command-line template. Instead, the part after the regular expression should be a full pathname to a file containing the log message template.
If the repository name does not match any of the regular expressions in this file, the `DEFAULT' line is used, if it is specified.
All occurances of the name `ALL' appearing as a regular expression are used in addition to the first matching regular expression or `DEFAULT'.
The log message template will be used as a default log message. If you specify a log message with `cvs commit -m message' or `cvs commit -f file' that log message will override the template.
See section Editinfo example, for an example `rcsinfo' file.
When CVS is accessing a remote repository, the contents of `rcsinfo' at the time a directory is first checked out will specify a template which does not then change. If you edit `rcsinfo' or its templates, you may need to check out a new working directory.
There are certain file names that frequently occur inside your working copy, but that you don't want to put under CVS control. Examples are all the object files that you get while you compile your sources. Normally, when you run `cvs update', it prints a line for each file it encounters that it doesn't know about (see section update output).
CVS has a list of files (or sh(1) file name patterns)
that it should ignore while running update
,
import
and release
.
This list is constructed in the following way.
RCS SCCS CVS CVS.adm RCSLOG cvslog.* tags TAGS .make.state .nse_depinfo *~ #* .#* ,* _$* *$ *.old *.bak *.BAK *.orig *.rej .del-* *.a *.olb *.o *.obj *.so *.exe *.Z *.elc *.ln core
$CVSIGNORE
is appended to the list.
In any of the 5 places listed above, a single exclamation mark (`!') clears the ignore list. This can be used if you want to store any file which normally is ignored by CVS.
The file `$CVSROOT/CVSROOT/history' is used
to log information for the history
command
(see section history--Show status of files and users). This file must be created to turn
on logging. This is done automatically if the
cvs init
command is used to set up the
repository (see section Creating a repository).
The file format of the `history' file is
documented only in comments in the CVS source
code, but generally programs should use the cvs
history
command to access it anyway, in case the
format changes with future releases of CVS.
Sometimes in writing an administrative file, you might want the file to be able to know various things based on environment CVS is running in. There are several mechanisms to do that.
To find the home directory of the user running CVS
(from the HOME
environment variable), use
`~' followed by `/' or the end of the line.
Likewise for the home directory of user, use
`~user'. These variables are expanded on
the server machine, and don't get any resonable
expansion if pserver (see section Direct connection with password authentication)
is in used; therefore user variables (see below) may be
a better choice to customize behavior based on the user
running CVS.
One may want to know about various pieces of
information internal to CVS. A CVS internal
variable has the syntax ${variable}
,
where variable starts with a letter and consists
of alphanumberic characters and `_'. If the
character following variable is a
non-alphanumeric character other than `_', the
`{' and `}' can be omitted. The CVS
internal variables are:
CVSROOT
RCSBIN
CVSEDITOR
VISUAL
EDITOR
USER
If you want to pass a value to the administrative files
which the user that is running CVS can specify,
use a user variable. To expand a user variable, the
administrative file contains
${=variable}
. To set a user variable,
specify the global option `-s' to CVS, with
argument variable=value
. It may be
particularly useful to specify this option via
`.cvsrc' (see section Default options and the ~/.cvsrc file).
For example, if you want the administrative file to
refer to a test directory you might create a user
variable TESTDIR
. Then if CVS is invoked
as cvs -s TESTDIR=/work/local/tests
, and the
administrative file contains sh
${=TESTDIR}/runtests
, then that string is expanded
to sh /work/local/tests/runtests
.
All other strings containing `$' are reserved; there is no way to quote a `$' character so that `$' represents itself.
This is a complete list of all environment variables that affect CVS.
$CVSIGNORE
$CVSWRAPPERS
$CVSREAD
checkout
and update
will
try hard to make the files in your working directory
read-only. When this is not set, the default behavior
is to permit modification of your working files.
$CVSROOT
$CVSROOT
is not set,
or if you wish to override it for one invocation, you
can supply it on the command line: `cvs -d cvsroot
cvs_command...' Once you have checked out a working
directory, CVS stores the appropriate root (in
the file `CVS/Root'), so normally you only need to
worry about this when initially checking out a working
directory.
$EDITOR
$CVSEDITOR
$CVSEDITOR
overrides
$EDITOR
. $CVSEDITOR
does not exist in
CVS 1.3, but the next release will probably
include it.
$PATH
$RCSBIN
is not set, and no path is compiled
into CVS, it will use $PATH
to try to find all
programs it uses.
$RCSBIN
$PATH
is searched.
$HOME
$HOMEPATH
$HOMEPATH
is used for Windows-NT).
see section Default options and the ~/.cvsrc file
$CVS_RSH
:ext:
access method is specified.
see section Connecting with rsh.
$CVS_SERVER
cvs
. see section Connecting with rsh
$CVS_PASSFILE
cvs
login server
. Default value is `$HOME/.cvspass'.
see section Using the client with password authentication
$CVS_PASSWORD
cvs
login server
.
see section Using the client with password authentication
$CVS_CLIENT_PORT
$CVS_RCMD_PORT
$CVS_CLIENT_LOG
$CVS_CLIENT_LOG
.in' and everything
send from the server is logged into
`$CVS_CLIENT_LOG
.out'.
$CVS_SERVER_SLEEP
$CVS_IGNORE_REMOTE_ROOT
$COMSPEC
$TMPDIR
$TMP
$TEMP
TMPDIR
. See section Global options, for a
description of how to specify this.
Some parts of CVS will always use `/tmp' (via
the tmpnam
function provided by the system).
On Windows NT, TMP
is used (via the _tempnam
function provided by the system).
The patch
program which is used by the CVS
client uses TMPDIR
, and if it is not set, uses
`/tmp' (at least with GNU patch 2.1).
CVS invokes RCS to perform certain operations. The following environment variables affect RCS. Note that if you are using the client/server CVS, these variables need to be set on the server side (which may or not may be possible depending on how you are connecting). There is probably not any need to set any of them, however.
$LOGNAME
$USER
$LOGNAME
.
$RCSINIT
$RCSINIT
options are prepended to the
argument lists of most RCS commands.
Externally, branch numbers consist of an odd number of dot-separated decimal integers. See section Revision numbers. That is not the whole truth, however. For efficiency reasons CVS sometimes inserts an extra 0 in the second rightmost position (1.2.3 becomes 1.2.0.3, 8.9.10.11.12 becomes 8.9.10.11.0.12 and so on).
CVS does a pretty good job at hiding these so called magic branches, but in a few places the hiding is incomplete:
cvs log
.
cvs
admin
.
You can use the admin
command to reassign a
symbolic name to a branch the way RCS expects it
to be. If R4patches
is assigned to the branch
1.4.2 (magic branch number 1.4.0.2) in file
`numbers.c' you can do this:
$ cvs admin -NR4patches:1.4.2 numbers.c
It only works if at least one revision is already committed on the branch. Be very careful so that you do not assign the tag to the wrong number. (There is no way to see how the tag was assigned yesterday).
Jump to: - - . - / - : - < - = - > - _ - a - b - c - d - e - f - g - h - i - j - k - l - m - n - o - p - r - s - t - u - v - w - z
This document was generated on 7 November 1998 using the texi2html translator version 1.52.