14.2.8.2. Working with CVS
In the following section, we will assume that either you or
your system administrator has set up a module called
dataimport. You can now check out a local tree of this
module with the following command:
$tigger cvs checkout dataimport
If there is no module defined for the project you want to
work on, you need to know the path within the repository. For
example, something like the following could be needed:
$tigger cvs checkout clients/acmeinc/dataimport
Whichever version of the checkout
command you use, CVS
will create a directory called
dataimport under your current working
directory and check
out all files and directories from the repository that belong to
this module. All files are writable, and you can start editing them
right away.
After you have made some changes, you can write back the
changed files into the repository with one single command:
$tigger cvs commit
Of course, you can also check in single files:
$tigger cvs commit importrtf.c
But whatever you do, CVS will ask you--as RCS does--for a comment to
include with your changes. But
CVS goes a step beyond
RCS in convenience. Instead of the
rudimentary prompt from RCS, you
get a full-screen editor to work in. You can
choose this editor by setting the environment variable
CVSEDITOR; if this is not set,
CVS looks in EDITOR, and if
this is not defined either, CVS
invokes vi.
If you
check in a whole project, CVS will use the
comment you entered for each directory in which there have been
changes but will start a new editor every time to ask you
whether you might want to change each file.
As already mentioned, it is not necessary to set
CVSROOT correctly for checking files in, because
when checking the tree out, CVS has created a
directory CVS in each work directory. This
directory contains all the information that CVS needs
for its work, including where to find the repository.
While you have been working on your files, it may well be that
a co-worker has checked in some of the files that you are currently
working on. In this case, CVS will not let you
check in your files but asks you to first update your local
tree. Do this with the command:
$tigger cvs update
M importrtf.c
A exportrtf.c
? importrtf
U importword.c
(You can specify a single file here as well.) You should
carefully examine the output of this command: CVS
outputs the names of all the files it handles, each preceded by a single key letter. This
letter tells you what has happened during the update operation. The
most important letters are shown in Table 14-1.
Table 14-1. Key Letters for Files Under CVS
Letter |
Explanation |
P |
The file has been updated. The P is shown if the file
has been added to the repository in
the meantime or if it has been
changed, but you have not made any changes to this file
yourself. |
U |
You have changed this file in the meantime, but
nobody else has. |
M |
You have changed this file in the meantime, and
somebody else has checked in a newer version. All the
changes have been merged successfully. |
C |
You have changed this file in the meantime, and
somebody else has checked in a newer version. During the
merge attempt, conflicts have arisen. |
? |
CVS has no information about this
file, that is, this file is not under CVS's
control. |
The C is the most important of those
letters. CVS was not able to merge all changes
and needs your help. Load those files into your editor and look for
the string <<<<<<<. After
this string, the name
of the file is shown again, followed by your version, ending with a line
containing =======. Then comes
the version of the code from the repository, ending
with a line containing
>>>>>>>. You now have to find out--probably by communicating with your co-worker--which version is better or whether it is possible to merge
the two versions by hand. Change the file accordingly and remove the
CVS markings <<<<<<<,
======= and
>>>>>>>. Save the file and
once again commit it.
If you decide that you want to stop working on a project for a
time, you should check whether you have really committed all
changes. To do this, change to the directory above the root
directory of your project and issue the command:
$tigger cvs release dataimport
CVS then checks whether you have written
back all changes into the repository and warns you if necessary. A
useful option is -d, which
deletes the local tree if all changes have been committed.