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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|