use Version::Rcs;
# called as class method $obj = Rcs->new;
# called as object method $newobj = $obj->new;
The bindir method sets the directory path where the RCS executables (i.e. rcs, ci, co) are located. The default location is '/usr/local/bin'.
# set RCS bin directory Rcs->bindir('/usr/bin');
# access RCS bin directory $bin_dir = Rcs->bindir;
The quiet method sets/unsets the quiet mode for the RCS executables. Quiet mode is set bt default.
# set/unset RCS quiet mode Rcs->quiet(0); # unset quiet mode Rcs->quiet(1); # set quiet mode
# access RCS quiet mode $quiet_mode = Rcs->quiet;
These methods may also be called as object methods.
$obj->bindir('/usr/bin'); $obj->quiet(0);
The file method is used to set the name of the RCS working file. The filename must be set before invoking any access of modifier methods on the object.
$obj->file('mr_anderson.pl');
The arcfile method is used to set the name of the RCS archive file. Using this method is optional, as the other methods will assume the archive filename is the same as the working file unless specified otherwise. The ',v' RCS archive extension is automatically added to the filename.
$obj->arcfile('principle_mcvicker.pl');
The workdir methods set the path of the RCS working directory. If not specified, default path is '.' (current working directory).
$obj->workdir('/usr/local/source');
The rcsdir methods set the path of the RCS archive directory. If not specified, default path is './RCS'.
$obj->rcsdir('/usr/local/archive');
The access method returns a list of all user on the access list.
@access_list = $obj->access;
The author method returns the author of the revision. The head revision is used if no revision argument is passed to method.
# returns the author of revision '1.3' $author = $obj->author('1.3');
# returns the authos of the head revision $author = $obj->author;
The head method returns the head revision.
$head = $obj->head;
The lock method returns the locker of the revision. The method returns null if the revision is unlocked. The head revision is used if no revision argument is passed to method.
# returns locker of revision '1.3' $locker = $obj->lock('1.3');
# returns locker of head revision $locker = $obj->lock;
The revisions method returns a list of all revisions of archive file.
@revisions = $obj->revisions;
The state method returns the state of the revision. The head revision is used if no revision argument is passed to method.
# returns state of revision '1.3' $state = $obj->state('1.3');
# returns state of head revision $state = $obj->state;
The sysbol method returns the sysbol(s)
associated with a revision. If
called in list context, method returns all symbols associated with
revision. If called in scalar context, method returns last symbol assciated
with revision. The head revision is used if no revision argument is passed
to method.
# list context, returns all symbols associated with revision 1.3 @symbols = $obj->symbol('1.3');
# list context, returns all symbols associated with head revision @symbols = $obj->symbol;
# scalar context, returns last symbol associated with revision 1.3 $symbol = $obj->symbol('1.3');
# scalar context, returns last symbol associated with head revision $symbol = $obj->symbol;
The ci method calls the RCS ci program.
# check in, and then check out in unlocked state $obj->ci('-u');
The co method calls the RCS co program.
# check out in locked state $obj->co('-l');
The rcs method calls the RCS rcs program.
# lock file $obj->rcs('-l');
The rcsdiff method calls the RCS rcsdiff program. When called in list context, this method returns the outpout of the rcsdiff program. When called in scalar context, this method returns the return status of the rcsdiff program. The return status is 0 for the same, 1 for some differences, and 2 for error condition.
When called without parameters, rcsdiff does a diff between the current working file, and the last revision checked in.
# call in list context @diff_output = $obj->rcsdiff;
# call in scalar context $changed = $obj->rcsdiff; if ($changed) { print "Working file has changed\n"; }
Call rcsdiff with parameters to do a diff between any two revisions.
@diff_output = $obj->rcsdiff('-r1.2', '-r1.1');
The rlog method calls the RCS rlog program. This method returns the output of the rlog program.
# get complete log output @rlog_complete = $obj->rlog;
# called with '-h' switch outputs only header information @rlog_header = $obj->rlog('-h'); print @rlog_header;
The rcsclean method calls the RCS rcsclean program.
# remove working file $obj->rcsclean;
use Version::Rcs; $obj = Rcs->new;
$obj->rcsdir("./project_tree/archive"); $obj->workdir("./project_tree/src"); $obj->file("cornholio.pl");
Methos rcs invokes the RCS utility rcs with the same parameters.
@users = qw(beavis butthead); $obj->rcs("-a@users");
Calling method access returns list of users on access list.
$filename = $obj->file; @access_list = $obj->access; print "Users @access_list are on the access list of $filename\n";
use Version::Rcs; Rcs->bindir('/usr/bin'); $obj = Rcs->new;
Set information regarding RCS object. This information includes name of the working file, directory of working file ('.' by default), and RCS archive directory ('./RCS' by default).
$obj->rcsdir("./project_tree/archive"); $obj->workdir("./project_tree/src"); $obj->file("cornholio.pl");
$head_rev = $obj->head; $locker = $obj->lock; $author = $obj->author; @access = $obj->access; @revisions = $obj->revisions;
$filename = $obj->file;
if ($locker) { print "Head revision $head_rev is locked by $locker\n"; } else { print "Head revision $head_rev is unlocked\n"; }
if (@access) { print "\nThe following users are on the access list of file $filename\n"; map { print "User: $_\n"} @access; }
print "\nList of all revisions of $filename\n"; foreach $rev (@revisions) { print "Revision: $rev\n"; }
use Version::Rcs; Rcs->bindir('/usr/bin'); Rcs->quiet(0); # turn off quiet mode $obj = Rcs->new;
Set information regarding RCS object. This information includes name of working file, directory of working file ('.' by default), and RCS archive directory ('./RCS' by default).
$obj->file('cornholio.pl');
# Set RCS archive directory, is './RCS' by default $obj->rcsdir("./project_tree/archive");
# Set working directory, is '.' by default $obj->workdir("./project_tree/src");
Check in file using C-u switch. This will check in the file, and will then check out the file in an unlocked state. The C-m switch is used to set the revision comment.
Command:
$obj->ci('-u', '-mRevision Comment');
is equivalent to commands:
$obj->ci('-mRevision Comment'); $obj->co;
use Version::Rcs; Rcs->bindir('/usr/bin'); Rcs->quiet(0); # turn off quiet mode $obj = Rcs->new;
Set information regarding RCS object. This information includes name of working file, directory of working file ('.' by default), and RCS archive directory ('./RCS' by default).
$obj->file('cornholio.pl');
# Set RCS archive directory, is './RCS' by default $obj->rcsdir("./project_tree/archive");
# Set working directory, is '.' by default $obj->workdir("./project_tree/src");
Check out file read-only:
$obj->co;
or check out and lock file:
$obj->co('-l');
$obj = Rcs->new; $obj->bindir('/usr/bin');
$obj->rcsdir("./project_tree/archive"); $obj->workdir("./project_tree/src"); $obj->file("cornholio.pl");
print "Diff of current working file\n"; if ($obj->rcsdiff) { # scalar context print $obj->rcsdiff; # list context } else { print "Versions are Equal\n"; }
print "\n\nDiff of revisions 1.2 and 1.1\n"; print $obj->rcsdiff('-r1.2', '-r1.1');
use Version::Rcs; Rcs->bindir('/usr/bin'); Rcs->quiet(0); # turn off quiet mode $obj = Rcs->new;
$obj->rcsdir("./project_tree/archive"); $obj->workdir("./project_tree/src"); $obj->file("cornholio.pl");
print "Quiet mode NOT set\n" unless Rcs->quiet;
$obj->rcsclean;