Tuesday, July 11, 2006

Useful CVS commands

This is a short list of commands that I've found useful in CVS. It's the kind of thing that I used frequently, but I'll forget exactly why and what each options means.

cvs -n -q update -d -P
The "-n" option instructs CVS not to change anything, just to produce a report. It causes the same output to be shown as if you did an update, but without actually doing the update.
The "-q" option makes output a little more terse than the default. For example, output such as "cvs update: Updating somedir" is not displayed.
The "-d" flag instructs CVS to include new directories that have been added since the last checkout. So any new directories will be checked out (if the -n option were not being used).
The "-P" flag tells CVS to purge (remove) any empty directories. Since there is no command to completely remove directories from CVS, this flag lets you remove them on your machine.

If you want CVS to ignore whitespace when comparing your version of the file somefile.txt with the version in CVS, do
cvs diff -b somefile.txt

When adding a binary file mybinfile to CVS, to be sure that CVS treats the file as binary, do
cvs add -kb mybinfile
See the CVS manual, section 9.2, on How to store binary files, for more details.

Suppose you have a file in CVS that has been edited in two separate branches. You can check out the two different branches of CVS, and use a file comparison utility such as diff to see what the differences are. Or, better, you can do it using CVS:
cvs diff -w -r 1.28 -r 1.27.4.1 Calculator.java
Obviously you need to know which revision numbers you're comparing. The log option may be helpful here:
cvs log Calculator.java
The output displays revision numbers and comments that were logged for the file with each revision, e.g. like this:

----------------------------
revision 1.2
date: 2006-04-10 04:02:42 +0000; author: employee1; state: Exp; lines: +15 -14
Made constructor private to avoid creating instances of class, which has only static methods.
----------------------------
revision 1.1
date: 2006-04-09 18:50:24 +0000; author: employee1; state: Exp;
Class uses static methods to compute several utility functions.

0 Comments:

Post a Comment

<< Home