# NOTE: All of the following functions assume
# That you've chdir()'d to some CVS working
# directory where the files specified reside.
# Get a file handle to the latest checked-in
# revision of test.c
my $fh = CVSUtil::open_revision("test.c");
while(<$fh>) { print $_; }
close $fh;
# Get a file handle to revision 1.1 of test.c
my $fh = CVSUtil::open_revision("test.c", "1.1");
while(<$fh>) { print $_; }
close $fh;
# Give the relative path (starting from the CVS
# root) to a file in CVS.
my $path = CVSUtil::get_cvs_path("test.c");
# => 'modulename/dir1/dir2/test.c'
# Get the revision number of the latest checked-in
# version of a file.
my $rev = CVSUtil::get_latest_revision("test.c");
# => '1.12'
# Set the path to the 'cvs' program for
# subsequent calls to CVSUtil functions
CVSUtil::cvs_command("/tools/bin/cvs");
A developer's CVS working directory often contains locally modified
copies of checked-in versions of files. While the cvs diff command
compares checked-in and local versions conveniently, there's no easy way
to the checked-in version itself.
CVSUtil tries to bridge this gap by providing
an easy-to-use programming interface to figure
out which version of a file has been checked into CVS last and,
upon request, opens this revision and provides a reading
file handle to it.
It uses cvs' local CVS/Root and CVS/Repository directories to
find out about the CVSROOT of the current project and the relative
location of the current subdirectory within the project.
If your system doesn't have the cvs command in your $PATH variable
(i.e. if you can't type cvs in your shell to call it), you need to tell
CVSUtil first, where it's located, before you start using any of the
commands listed below. The function returns the new setting of the
path to the cvs command. If called without parameters, it returns the
current setting.
Opens revision $rev of $filename and returns a read-only file handle
to it. Note that you need to chdir() into a CVS working directory containing
the file $filename, first. If $rev is not specified,
open_revision() will use get_latest_revision() to determine
the most recently checked-in version and provide a file handle to it.
Figures out the revision number of the most recently checked-in version
of the file $filename. Note that you need to chdir() into a CVS working
directory containing the file $filename, first. Returns the revision
number as a string (e.g. "1.12") and undef in case of an error.
Determines the relative path to $filename, starting from the CVS's
root directory. Note that you need to chdir() into a CVS working
directory containing the file $filename, first.
E.g., if you're in projectname/dir1/dir2 and you call
get_cvs_path("test.c"), you'll get "projectname/dir1/dir2/test.c"
back, even if your local working directory is not projectname/dir1/dir2
but something like myproject-1.1/dir1/dir2.
Copyright 2002 by Mike Schilli, all rights reserved.
This program is free software, you can redistribute it and/or
modify it under the same terms as Perl itself.