Cvs

From ConShell
(Redirected from Cvs Tips)
Jump to navigation Jump to search

Introduction

I use cvs extensively to store and retrieve all kinds of data -- websites, configuration files (such as in conjunction with CFengine), code and reference data. Here is what my typical ~/.cvsrc file contains:

 cvs -q
 diff -u -b -B
 checkout -P
 update -d -P

I also like to define the following alias to quickly surmise the "state" of a sandbox.

 alias cvstat "cvs -q status | grep Status | grep -v 'Up-to'"

I put the following lines into my .cshrc on the client...

 setenv CVSROOT mdf@home:/var/cvs
 setenv CVS_RSH ssh

I locate my repositories in /var/cvs whenever I can because it is short and easy to remember.

administration and maintenance

Here's how to prepare a repository for actual files

 cvs init

Import an entire tree into the repository

 cvs import -m "commit message goes here" modulename mdf base

Where: modulename is the name of the module such as nodetrack mdf is the name of the author or vendor (me) base is the tag for the default branch (aka head)

It is good practice to enforce strict permissions on the repository so that not just anyone can go perusing code.

 chmod -R o-rwx /var/cvs


To enable a group of developers to work on a shared codebase, you can assign group perms on a module by issuing the following commands. if test1 is the repository

 chgrp -R groupname /var/cvs/test1
 chmod -R g+ws /var/cvs/test1
 chmod -R o-rwx /var/cvs/test1

tagging

Assign a tag "RELEASE_1_1_1" to all the current (committed) files in module1

 cvs rtag -R RELEASE_1_1_1 module1

Extract for same tag

 cvs export  -r "RELEASE_TAG_1_1_1" module1

fixing mistakes

Sometimes you might make a bad commit and need to "rollback". Using cvs log and cvs diff determine which version of a file has the "good" data. For instance, if cfagent.conf v1.478 is determined good, do

mv cfagent.conf cfagent.conf.borked
cvs update -r1.478 cfagent.conf

Make any outstanding fixes (probably ascertained with diff -u cfagent.conf cfagent.conf.borked) and merge back into cfagent.conf. Upon attempting to commit this, there will be an indication of a "tagged" version... also visible in CVS/Entries. To clear the tag move cfagent.conf to .good, then do

cvs update -A cfagent.conf <-- this clear the sticky version tag on cfagent.conf
mv cfagent.conf.good cfagent.conf
cvs commit cfagent.conf

That should do it!

commit notifications

  • Edit CVSROOT/notify and uncomment the line starting with ALL

(To do this may mean becoming root and cvs co CVSROOT, edit then commit)

  • Then copy the log.pl script from contrib
 cp /usr/share/cvs/contrib/log CVSROOT/log.pl
 cvs add CVSROOT/log.pl
  • Edit CVSROOT/loginfo

^cfengine* $CVSROOT/CVSROOT/log.pl %s -m mdf@example.org -f $CVSROOT/CVSROOT/commitlog

 commit

Note: commitlog needs write permissions to all who might commit See Chap 3 of the open source development with CVS book for more details

other tips (some learned the hard way!)

  • save time - always run cvs update before a commit!



Here are some of my bookmarks for CVS-related info.