Karim Nassar & Frank Wallingford, October 2002
CVS (Concurrent Versions System) is a program that allows one to maintain
a version history for documents. Normally, this is used for code, but
CVS can be used for any type of files. If you write code, you want to
use this. This page describes the basics for getting started on Denali.
Naturally, it is recommended you read the man page and/or the Cederqvist
online documentation.
Repository is the term used for the location on the CVS server
where the code history is kept. You must create one of these in order
to use CVS. You can create a repository for a brand new project with
nothing existing yet, or (more commonly) create a repository for an
already existing code tree. Note that the cvs commands given in this
section are described in greater detail in the Accessing the Repository Remotely
section.
New repository, no pre-existing code
- Create a directory under
/research/cvsroot/<repository-name>
chmod the directory to have appropriate permissions
(see "Set Appropriate Permissions"
below).
cd to a new directory and checkout the current repository:
cd /home/me
cvs -d :ext:<username>@denali.cse.nau.edu:/research/cvsroot/
co <repository-name>
- There will now be a directory
/home/me/<repository-name>.
Add things to this directory and check them in to the repository using
CVS commands.
New repository, preexisting code
cd into the top level directory of where your code
lives. Executing the following command will create the repository
by recursively decending this directory adding all files into it:
cd /home/me/gonna-cvs-this-code
cvs -d :ext:<username>@denali.cet.nau.edu:/research/cvsroot
import <repository-name> <vendor-tag> <release-tag>
Where:
<repository-name> : the name of the directory that
will be created within the CVS root, and the name of the repository
<vendor-tag> :
the name of the vendor (Required, but not important. I have never
used this.)
<release-tag> :
the name of this release (See above note for vendor-tag)
cd somewhere else and cvs checkout the
repository to finish the setup:
cd /home/me/work/
cvs -d :ext:<username>@denali.cet.nau.edu:/research/cvsroot
checkout <repository-name>
Now that you have everything in CVS, you really don't need the originals.
You can remove them if you like:
rm -rf /home/me/gonna-cvs-this-code
chmod and chgrp the /research/cvsroot/<repository-name>
directory to have appropriate permissions (see following).
Set Appropriate Permissions
- By default, your repository will be owned by you, be in your group,
and have 775 permissions.
ls -l /research/cvsroot will
output:
drwxrwxr-x <username> <username>
<repository-name>
This means that nobody but you can checkout the repository.
(Users need write permission to be able to checkout.)
- If you would like group members to be able to add files to the
repository you need change the group of the repository with the
chgrp
command then make sure that the group has write permissions (chmod
g+w <repository> if necessary) .
- Note that the owner of a file is the only person who can directly
delete files from
/research/cvsroot/<repository>
(This is not recommended however. CVS has ways to remove things without
directly manipulating the repository). Contrarily, in subdirectories,
the group permissions prevail. Also, whomever adds to the repository,
owns the file in the repository.
When CVS starts up, it reads the .cvsrc file from your
home directory. This startup procedure can be turned off with the -f
flag.
The .cvsrc file lists CVS commands with a list of arguments,
one command per line. For example, the following line in .cvsrc:
update -d
will mean that the cvs update command will always be
passed the -d option in addition to any other options that are specified
in the command line. In this case it will have the effect of telling
the update command to not only update files that are in
your copy of the code, but copy new directories and files that are in
the repository, but not in your code tree. (I recommend you use this.)
It is very common to have the CVS repository for a project on a remote
server. Denali is set up to allow you access to the repository through
SSH. The following describes this remote access.
- Initial Requirements
- Make sure in
~/.cvsrc you have "update -d" (see
"Using a .cvsrc File")
- Set SSH to be your RSH client in your shell configuration file.
Do one of the following depending on which shell you use. (You
have a bash shell unless you requested otherwise, so append the
.bashrc file.) :
echo "export CVS_RSH='ssh'" >>
~/.bashrc
OR
echo "set CVS_RSH ssh" >> ~/.cshrc
For this to take effect, you should do:
source ~/.bashrc
- Do only one of the next steps to have CVS either ask or don't
ask for a password
- Do this to have CVS always ask for your Denali password:
- Do the initial checkout of the repository:
cvs -d :ext:<uid>@denali.cse.nau.edu:/research/cvsroot/ checkout
<repository-name>
- You will be asked for your Denali password
NOTE: From this point forward, as long as you are in
a directory within your local copy of the repository, every
CVS command will ask for your Denali password, but you don't
need to type
-d :ext:<uid>@denali.cse.nau.edu:/research/cvsroot/
for every cvs command.
OR
- Do this to have CVS never ask for your Denali password
- One time only, while on Denali, make yourself an SSH1 key
with no passphrase.
Do:
ssh-keygen -t rsa1
This command makes two files: ~/.ssh/identity
and ~/.ssh/identity.pub.
- Append your public identity to your autorized keys list.
Do:
cat ~/.ssh/identity.pub >> ~/.ssh/authorized_keys
- Set permissions so nobody else can access these files (except
root)
Do:
chmod go-rwx .ssh
chmod go-rwx .ssh/authorized_keys
- Edit
~/.ssh/authorized_keys by prepending command="cvs server"
plus one space at the front of the top line so it looks like:
command="cvs server" 1024 <rest-of-key>
NOTE: If you trust the superusers of Denali (currently
Eck, Karim, and Frank) you don't need to do this step, and
SSH and all associated commands (sftp, scp, cvs, etc) will
never ask you for a password. Your choice.
- Copy the
~/.ssh/identity file to each client
you want to run cvs commands from.
- Do:
cvs -d :ext:<username>@denali.cse.nau.edu:/research/cvsroot/ checkout
<repository-name>
on the client when you want to check out code.
- You don't need
~/.ssh/identity on Denali.
Delete it if you don't want to copy it to other computers.
NOTE:As long as ~/.ssh/identity exists on
remote computers, SSH uses it by default, and will let you run
CVS commands without entering a password.
- Example Remote Commands
I am kan4, and I want to work on my project on CET to insure it cross-compiles
to solaris-sparc. I do:
cvs -d :ext:kan4@denali.cse.nau.edu:/research/cvsroot/sparkyLinux checkout
A directory sparkyLinux will be created in my current
working directory on CET. As long as I am somewhere within this copy
of the repository, CVS knows that the original repository is on Denali.
So, after I make my changes, I can do these simpler commands:
cvs update (VERY IMPORTANT. This makes sure
the local copy is current with the repository.)
cvs commit (Commit my changes to the repository)
NOTE: These commands (as do most CVS commands) affect the current
working directory and recursively down.
Here is a synopsis of some common CVS commands that you will likely
use. Note that many commands have synonyms. For example, cvs co
is equivalent to cvs checkout. Complete usage is covered
in the man page.
- add
- Add a new file or directory to the repository, pending a `cvs commit'
on the same file. Can only be done from within sources created by
a previous `cvs checkout' invocation. Use `cvs import' to place whole
new hierarchies of sources under cvs control. (Does not directly affect
repository; changes working directory.)
- checkout
- Make a working directory of source files for editing. (Creates
or changes working directory.)
- commit
- Apply to the source repository changes, additions, and deletions
from your working directory. (Changes repository.)
- diff
- Show differences between files in working directory and source
repository, or between two revisions in source repository. (Does not
change either repository or working directory.)
- history
- Show reports on cvs commands that you or others have executed on
a particular file or directory in the source repository. (Does not
change repository or working directory.) History logs are kept only
if enabled by creation of the `$CVSROOT/CVSROOT/history' file; see
cvs(5).
- import
- Incorporate a set of updates from off-site into the source repository,
as a ``vendor branch''. (Changes repository.)
- log
- Display log information. (Does not change repository or working
directory.)
- release
- Cancel a `cvs checkout', abandoning any changes. (Can delete working
directory; no effect on repository.)
- remove
- Remove files from the source repository, pending a `cvs commit'
on the same files. (Does not directly affect repository; changes working
directory.)
- status
- Show current status of files: latest version, version in working
directory, whether working version has been edited and, optionally,
symbolic tags in the RCS file. (Does not change repository or working
directory.)
- update
- Bring your working directory up to date with changes from the repository.
Merges are performed automatically when possible; a warning is issued
if manual resolution is required for conflicting changes. (Changes
working directory; does not change repository.)
|