I actually wrote a nifty web-based code review tool that is built around CVS. (I might release it someday if my company will allow it :) Here is how I did the CVS part of it. This code uses IPC to talk to CVS and retrieves a specific version number out of CVS and runs it through enscript to color-code it. The enscript part is just for fun :)
my $cobin = "/usr/local/bin/co";
my $enscript = "/usr/local/bin/enscript";
my $cvs_repos = "/path/to/cvs/repository";
my $rev = "1.1"
my $file = "script.pl";
open(CVS, "$cobin -r$rev -p $cvs_repos/$file 2>&1 |");
@code = <CVS>;
# write it to a temp file so enscript can use it
open(TMPCVS, ">/tmp/tmpcvs.$$");
foreach (@code) { print TMPCVS $_; }
close(CVS, TMPCVS);
# the 2>/dev/null drops all stderr text, which is usually "output left
+ in -". This would have ended up either in the code
# or the log file.
open(ENSCRIPT, "$enscript --pretty-print=perl -G --language=html --col
+or -p- /tmp/tmpcvs.$$ 2>/dev/null |");
my @source = <ENSCRIPT>;
close(ENSCRIPT);
unlink("/tmp/tmpcvs.$$");
Probably a little bit more there than what you needed, but hopefully that can help answer your question. You might also want to check out the Python script ViewCVS. I fumbled my way through this in order to figure out how to use the 'co' command. |