NAME
Rcs - Perl Class for Revision Control System (RCS).
SYNOPSIS
use Version::Rcs;
DESCRIPTION
This Perl module provides an object oriented interface to access Revision Control System (RCS) utilities. RCS must be installed on the system prior to using this module. This module should simplify the creation of an RCS front-end.
OBJECT CONSTRUCTOR
The new method may be used as either a class method or an object method to create a new object.
# called as class method
$obj = Rcs->new;
# called as object method
$newobj = $obj->new;
CLASS METHODS
Besides the object constructor, there are two class methods provided which effect any newly created objects.
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);
OBJECT ATTRIBUTE METHODS
These methods set the attributes of the RCS object.
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');
RCS PARSE METHODS
This class provides methods to directly parse the RCS archive file.
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;
RCS SYSTEM METHODS
These methods invoke the RCS system utilities.
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;
EXAMPLES
CREATE ACCESS LIST
Using method rcs with the C-a switch allows you to add users to the access list of an RCS archive file.
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";
PARSE RCS ARCHIVE FILE
Set class variables and create 'RCS' object. Set bin directory where RCS programs (e.g. rcs, ci, co) reside. The default is '/usr/local/bin'. This sets the bin directory for all objects.
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";
}
CHECK-IN FILE
Set class variables and create 'RCS' object. Set bin directory where RCS programs (e.g. rcs, ci, co) reside. The default is '/usr/local/bin'. This sets the bin directory for all objects.
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;
CHECK-OUT FILE
Set class variables and create 'RCS' object. Set bin directory where RCS programs (e.g. rcs, ci, co) reside. The default is '/usr/local/bin'. This sets the bin directory for all objects.
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');
RCSDIFF
Method rcsdiff does an diff between revisions.
$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');
RCSCLEAN
Method rcsclean will remove an unlocked working file.
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;
AUTHOR
Craig Freter, <craig@freter.com>
COPYRIGHT
Copyright (C) 1997, Craig Freter. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.