Tame Your Wild Config Herds with CVS - Page 2

By Carla Schroder | Posted Apr 15, 2003
Page 2 of 2   |  Back to Page 1
Print ArticleEmail Article
  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn
Checking Files In and Out
CVS can do a zillion and one things; the five primary commands most users rely on are checkout, update, add, remove, commit and diff. To add new files to a repository, change to the directory they are stored in. You must do this or it won't work. Make sure the directory structure is set up the way you want. The syntax is cvs import modulename vendortag releasetag:

$ cd ~/cvs/postfix_configs
$ cvs import /cvs/postfix postfix ver_1

Don't worry about vendor tags and release tags. Modules are related collections of files, usually the directory tree for a specific project (in this case a collection of Postfix configuration files). Because it is a homegrown project, rather than vendor-supplied, the vendor tags and release tags can be anything. CVS merely requires that they be present.

It is important to use the complete filepath after /home, as illustrated above. If the directory to be imported was /home/postfix_configs, then it would look like this:

$ cd ~/postfix_configs
$ cvs import postfix postfix ver_1

A logfile will open during this operation, using the editor defined in your bash profile. If none is defined, you'll get vi, as that is the default. Making useful log notes is essential, because you will forget what you do. A shortcut is to put your log entry in the command line:

$ cvs import "three versions of main.cf for different connection types" postfix postfix ver_1

Now let's check them back out. Change to the directory you want to download the files into, then check them out from the repository. This creates a postfix directory, with all the files, plus a CVS directory. Don't touch this, it is for CVS internal use only.

$ cvs checkout postfix
$ ls

CVS main_cf_1 main_cf_2 main_cf_3

So we futz with main.cf_1 for a bit, making it all new and improved. When we're done, it's time to put it back in the repository:

$ cvs commit main.cf_1

More Commands
A most useful option is the "dry-run" switch; cvs -n [command] lets you see what a command will do before actually doing it.

cvs update
Execute this from within your local source directory to incorporate any changes made in the central repository. This is more useful when there are multiple authors on a project, for keeping everyone in sync.

cvs add
Use this for adding files to an existing module, in your local source directory. They will be added to the repository the next time you run the 'cvs commit' command.

cvs remove
This works the same way as cvs add; remove the files from the local directory, then execute cvs commit to affect the repository. The files are moved to the CVS Attic, so they are still available, but not in the way.

cvs diff
Compare your local copy with the version in the repository.

cvs history -a -o
Show all the checked-out modules.

cvs history -a -e
Show all available status information

What Not to Do
The whole purpose of CVS is to track and record all changes. Don't try to be ultra lean and go on CVS housecleaning binges; leave it alone. It's supposed to keep everything forever -- which it does most efficiently.

Resources
/usr/doc/cvs
CVS-RCS-HOWTO Document for Linux
Essential CVS, by Jenn Vesperman


» See All Articles by Columnist Carla Schroder

Comment and Contribute
(Maximum characters: 1200). You have
characters left.
Get the Latest Scoop with Enterprise Networking Planet Newsletter