LinuxDevCenter.com
oreilly.comSafari Books Online.Conferences.

advertisement


CVS Administration

by Jennifer Vesperman
01/17/2002

CVS--or Concurrent Versioning System--is a tool for saving the user's butt by maintaining a history of changes. It allows for the retrieval of older versions of files, records who makes each change, and prevents simultaneous changes from overwriting each other.

CVS expects the files it maintains to be stored in modules-- directories of related files and subdirectories. A module can be as small as a single directory containing a single file, or as large as the amount of disk space you have available.

Companion Article

This article is a companion to Introduction to CVS, which covers the use of a CVS repository. This article covers building and maintaining the repository, and discusses some of the most common issues faced by CVS administrators.

Creating a Repository

The repository needs to be hosted on a machine with sufficient disk space to store all your files and all the data for the changes you expect. As a rule of thumb, put the repository on a partition with enough room for three times the expected final size of the module. Then use the "Scotty principle," and double your estimate-- the project will expand. If you intend to store binary files, multiply by ten. After your first project, you'll have a feel for how much space to allow.

Ensure that all users have access to the repository machine from all the machines they intend to use.

Create your repository root directory. Repositories are often stored in /home/cvsroot or /usr/local/cvsroot. Use cvs init to set up the directory as a CVS repository.

cvs -d /home/cvsroot init

Debian Linux has a script, cvs-makerepos, which will build a repository based on pre-existing Debian configuration scripts. See man cvs-makerepos for more information and man cvsconfig for an automated system for configuring a Debian CVS repository.

Importing a New Module

Before loading your project into CVS, consider its structure. Moving or renaming files and directories can damage the CVS record of the files' history. Deleting a directory can cost you the record of all its files and subdirectories. For this reason, CVS has no facility for moving or renaming files and directories, or removing directories.

Make your initial directory structure--even if it's just one directory. Add any initial files you want. From within the root directory of your project, use the command cvs -d cvs repository import nameofmodule vendortag releasetag.

For most cases, you will not need to know about vendor tags and release tags. CVS requires them to be present, but you can simply use the name of the module as the vendor tag, and the current version as the release tag.

/home/jenn$ cd example
/home/jenn/example$ cvs -d /home/cvsroot import example example_project ver_0-1

Using Tags

Tags assign a symbolic name to a revision of a file or a set of files. cvs tag tags the repository versions of all the files in the current working directory and its subdirectories.

The cvs rtag command is based on a timestamp. It assigns the symbolic name to the version of the file or directory that is closest to and older than the timestamp; it does not look at the working directory.

Note that CVS doesn't allow the '.' character in tags.

cvs tag tagname filename
cvs tag tagname

(Tags the repository versions of all files in the current working directory.)

cvs tag -c tagname 

(Aborts if the repository copy differs from the working copy.)

Example:

cvs/example$ cvs tag release-1-0 src/sample.c
cvs/example/src$ cvs tag release-1-0 
cvs/example/src$ cvs tag -c release-1-0

To retrieve a tagged version, use the -r flag to checkout or update. If you checkout or update in your usual working directory, the tagged version will overwrite the existing files.

cvs checkout -r tagname
cvs update -r tagname

Example:

cvs$ mkdir example-rel-1.0
cvs/example-rel-1.0$ cvs checkout -r release-1-0

or

cvs/example$ cvs update -r release-1-0

Branching Development

If you need to fix a bug in an older version of your code without changing current code, or modify a configuration set for staging servers without modifying the set for your production servers, you might need to branch your modules. A branch allows storage and retrieval of a variation of the main module, without affecting the main module. Changes on the branch can be merged in later.

To make a branch:

cvs tag -b branchtag

Example:

cvs/example$ cvs tag -b release-1-0-patches

Retrieve a branch using either checkout or update. Checkout will create a new directory for the branch, and update will overwrite your current working directory with the branch.

cvs checkout -r branchtag
cvs update -r branchtag

Example:

cvs/example-rel-1.0$ cvs checkout -r release-1-0-patches
cvs/example$ cvs update -r release-1-0-patches

Branches can be merged back into the main trunk, using the conflict resolution system invoked by cvs update and cvs commit.

cvs checkout module
cvs update -j branchtag

Example:

/tmp/example$ cvs checkout example
/tmp/example$ cvs update -j release-1-0-patches

Or in a single command:

cvs checkout -j branchtag module

Example:

/tmp/example$ cvs checkout -j release-1-0-patches example

Resolve any conflicts the system reports, then cvs commit.

Pages: 1, 2

Next Pagearrow




Linux Online Certification

Linux/Unix System Administration Certificate Series
Linux/Unix System Administration Certificate Series — This course series targets both beginning and intermediate Linux/Unix users who want to acquire advanced system administration skills, and to back those skills up with a Certificate from the University of Illinois Office of Continuing Education.

Enroll today!


Linux Resources
  • Linux Online
  • The Linux FAQ
  • linux.java.net
  • Linux Kernel Archives
  • Kernel Traffic
  • DistroWatch.com


  • Sponsored by: