CVS goodies

I use CVS (Concurrent Versioning System; CVS in wikipedia) regularly to track software, user’s guides, and technical papers that I write. The ability to track different versions, and roll back when absolutely necessary, is a wonderful safety net to have. When collaborating with others, the fact that we can all be working on our own copies at the same time is a productivity boon. I also like being able to review log messages covering a given file’s evolutionary history. (And no, I am not going to discuss the merits of CVS versus SVN (Subversion); there’s plenty of that all over the net for you to enjoy.)

Today, thanks to a co-worker’s presentation and some ensuing research, I learned some new CVS tricks that promise to make it an even more useful tool for me:

cvs admin -m rev:msg

Update the log message for revision “rev” to be “msg”. While some might wince at the potential for revisionist (*snerk*) activity, this will be oh-so-handy for fixing those typos you notice only after hitting enter on your cvs commit -m "My messge goes hre".

cvs checkout -D "1 hour ago"

(Or, ye gads, -D “1 week ago”, depending on the level of panic you’re experiencing with oh-my-god-it’s-BROKEN!) Check out the version of each file that was current as of the specified date. You can use absolute dates, too, but the relative thing is pretty darn cool!

cvs tag -D "6/5/07" tag last_known_good

Tag all files as of the specified date (relative dates good here, too!) with the “last_known_good” tag. Ultra-useful if you need to go back in time and tag a release that you meant to tag before you went and modified a bunch of files.

cvs annotate filename

Annotate each line of “filename” with the last revision in which it was modified. Also shows who was the modifier. Fun pipeline:
cvs annotate filename | cut -f2 -d'(' | cut -f1 -d' ' | sort | uniq -c
This will show a count next to each author indicating how many of the “most recent changes” they are responsible for.

cvs watch add filename

Receive email whenever “filename” is modified by someone. Note: cvs watch on filename is quite different; it turns on read-only checkouts of “filename”. Developers would then need to issue cvs edit filename to get a writeable version of “filename”, which alerts others to their actions. Also, they then are listed when cvs editors filename is issued.

What are your favorite CVS commands?