The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
<HTML>
<HEAD>
<TITLE>Rcs - Perl Object Class for Revision Control System.</TITLE>
<LINK REV="made" HREF="mailto:bhcompile@stripples.devel.redhat.com">
</HEAD>

<BODY>

<A NAME="__index__"></A>
<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#name">NAME</A></LI>
	<LI><A HREF="#synopsis">SYNOPSIS</A></LI>
	<LI><A HREF="#description">DESCRIPTION</A></LI>
	<UL>

		<LI><A HREF="#object constructor">OBJECT CONSTRUCTOR</A></LI>
		<LI><A HREF="#class methods">CLASS METHODS</A></LI>
		<LI><A HREF="#object attribute methods">OBJECT ATTRIBUTE METHODS</A></LI>
		<LI><A HREF="#rcs parse methods">RCS PARSE METHODS</A></LI>
		<LI><A HREF="#rcs system methods">RCS SYSTEM METHODS</A></LI>
	</UL>

	<LI><A HREF="#examples">EXAMPLES</A></LI>
	<UL>

		<LI><A HREF="#create access list">CREATE ACCESS LIST</A></LI>
		<LI><A HREF="#parse rcs archive file">PARSE RCS ARCHIVE FILE</A></LI>
		<LI><A HREF="#checkin file">CHECK-IN FILE</A></LI>
		<LI><A HREF="#checkout file">CHECK-OUT FILE</A></LI>
		<LI><A HREF="#rcsdiff">RCSDIFF</A></LI>
		<LI><A HREF="#rcsclean">RCSCLEAN</A></LI>
	</UL>

	<LI><A HREF="#author">AUTHOR</A></LI>
	<LI><A HREF="#contributors">CONTRIBUTORS</A></LI>
	<LI><A HREF="#copyright">COPYRIGHT</A></LI>
</UL>
<!-- INDEX END -->

<HR>
<P>
<H1><A NAME="name">NAME</A></H1>
<P>Rcs - Perl Object Class for Revision Control System (RCS).</P>
<P>
<HR>
<H1><A NAME="synopsis">SYNOPSIS</A></H1>
<PRE>
    use Rcs;</PRE>
<PRE>
    # Use tags to control how the rcs programs handle errors
    # and the use of the rcs -q (quiet) flag.
    use Rcs qw(nonFatal Verbose);</PRE>
<P>The default behavior is to run rcs programs with the -q (quiet) flag,
and to die if any rcs program returns an error.</P>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A></H1>
<P>This Perl module provides an object oriented interface to access 
<STRONG>Revision Control System (RCS)</STRONG> utilities.  RCS must be installed on
the system prior to using this module.  This module should simplify
the creation of an RCS front-end.</P>
<P>
<H2><A NAME="object constructor">OBJECT CONSTRUCTOR</A></H2>
<P>The <STRONG>new</STRONG> method may be used as either a class method or an object
method to create a new object.</P>
<PRE>
    # called as class method
    $obj = Rcs-&gt;new;</PRE>
<PRE>
    # called as object method
    $newobj = $obj-&gt;new;</PRE>
<P>Note: You may now set the pathname of the working file through the object
constructor.  This is the same as calling the pathname method after
calling the new method.</P>
<P>Thus</P>
<PRE>
    $obj = Rcs-&gt;new($pathname);</PRE>
<P>is the same as</P>
<PRE>
    $obj = Rcs-&gt;new;
    $obj-&gt;pathname($pathname);</PRE>
<P>See <STRONG>pathname</STRONG> method for additional details.</P>
<P>
<H2><A NAME="class methods">CLASS METHODS</A></H2>
<P>Besides the object constructor, there are three class methods provided
which effect any newly created objects.</P>
<P>The <STRONG>arcext</STRONG> method sets the RCS archive extension, which is ',v' by
default.</P>
<PRE>
    # set/unset RCS archive extension
    Rcs-&gt;arcext('');            # set no archive extension
    Rcs-&gt;arcext(',v');          # set archive extension to ',v'
    $arc_ext = Rcs-&gt;arcext();   # get current archive extension</PRE>
<P>The <STRONG>bindir</STRONG> method sets the directory path where the RCS executables
(i.e. rcs, ci, co) are located.  The default location is '/usr/local/bin'.</P>
<PRE>
    # set RCS bin directory
    Rcs-&gt;bindir('/usr/bin');</PRE>
<PRE>
    # access RCS bin directory
    $bin_dir = Rcs-&gt;bindir;</PRE>
<P>The <STRONG>quiet</STRONG> method sets/unsets the quiet mode for the RCS executables.
Quiet mode is set by default.</P>
<PRE>
    # set/unset RCS quiet mode
    Rcs-&gt;quiet(0);      # unset quiet mode
    Rcs-&gt;quiet(1);      # set quiet mode</PRE>
<PRE>
    # access RCS quiet mode
    $quiet_mode = Rcs-&gt;quiet;</PRE>
<P>These methods may also be called as object methods.</P>
<PRE>
    $obj-&gt;arcext('');
    $obj-&gt;bindir('/usr/bin');
    $obj-&gt;quiet(0);</PRE>
<P>
<H2><A NAME="object attribute methods">OBJECT ATTRIBUTE METHODS</A></H2>
<P>These methods set the attributes of the RCS object.</P>
<P>The <STRONG>file</STRONG> 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.</P>
<PRE>
    $obj-&gt;file('mr_anderson.pl');</PRE>
<P>The <STRONG>arcfile</STRONG> 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
RCS archive extension (default ',v') is automatically added to the filename.</P>
<PRE>
    $obj-&gt;arcfile('principle_mcvicker.pl');</PRE>
<P>The <STRONG>workdir</STRONG> methods set the path of the RCS working directory.  If not
specified, default path is '.' (current working directory).</P>
<PRE>
    $obj-&gt;workdir('/usr/local/source');</PRE>
<P>The <STRONG>rcsdir</STRONG> methods set the path of the RCS archive directory.  If not
specified, default path is './RCS'.</P>
<PRE>
    $obj-&gt;rcsdir('/usr/local/archive');</PRE>
<P>The <STRONG>pathname</STRONG> method will set both the working filename and archive
directory.</P>
<PRE>
    $obj-&gt;pathname($RCS_DIR . '/' . 'butthead.c');
and
    $obj-&gt;pathname($RCS_DIR . '/' . 'butthead.c,v');</PRE>
<P>are the same as</P>
<PRE>
    $obj-&gt;rcsdir($RCS_DIR);
    $obj-&gt;file('butthead.c');</PRE>
<P>
<H2><A NAME="rcs parse methods">RCS PARSE METHODS</A></H2>
<P>This class provides methods to directly parse the RCS archive file.</P>
<P>The <STRONG>access</STRONG> method returns a list of all user on the access list.</P>
<PRE>
    @access_list = $obj-&gt;access;</PRE>
<P>The <STRONG>author</STRONG> method returns the author of the revision.  The head revision
is used if no revision argument is passed to method.</P>
<PRE>
    # returns the author of revision '1.3'
    $author = $obj-&gt;author('1.3');</PRE>
<PRE>
    # returns the authos of the head revision
    $author = $obj-&gt;author;</PRE>
<P>The <STRONG>head</STRONG> method returns the head revision.</P>
<PRE>
    $head = $obj-&gt;head;</PRE>
<P>The <STRONG>lock</STRONG> 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.  When called in list context the lock method
returns a hash of all locks.</P>
<PRE>
    # returns locker of revision '1.3'
    $locker = $obj-&gt;lock('1.3');</PRE>
<PRE>
    # returns locker of head revision
    $locker = $obj-&gt;lock;</PRE>
<PRE>
    # return hash of all locks
    %locks = $obj-&gt;lock;    # called in list context
    foreach $rev (keys %locks) {
        $locker = $locks{$rev};
        print &quot;User $locker has revision $rev locked\n&quot;;
    }</PRE>
<P>The <STRONG>revisions</STRONG> method returns a list of all revisions of archive file.</P>
<PRE>
    @revisions = $obj-&gt;revisions;</PRE>
<P>The <STRONG>state</STRONG> method returns the state of the revision. The head revision
is used if no revision argument is passed to method.</P>
<PRE>
    # returns state of revision '1.3'
    $state = $obj-&gt;state('1.3');</PRE>
<PRE>
    # returns state of head revision
    $state = $obj-&gt;state;</PRE>
<P>The <STRONG>symbol</STRONG> method returns the <CODE>symbol(s)</CODE> 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 a revision.  The head revision is used if no revision argument
is passed to method.</P>
<PRE>
    # list context, returns all symbols associated with revision 1.3
    @symbols = $obj-&gt;symbol('1.3');</PRE>
<PRE>
    # list context, returns all symbols associated with head revision
    @symbols = $obj-&gt;symbol;</PRE>
<PRE>
    # scalar context, returns last symbol associated with revision 1.3
    $symbol = $obj-&gt;symbol('1.3');</PRE>
<PRE>
    # scalar context, returns last symbol associated with head revision
    $symbol = $obj-&gt;symbol;</PRE>
<P>The <STRONG>symbols</STRONG> method returns a hash, keyed by symbol, of all of the revisions
associated with the file.</P>
<PRE>
    %symbols = $obj-&gt;symbols;
    foreach $sym (keys %symbols) {
        $rev = $symbols{$sym};
    }</PRE>
<P>The <STRONG>revdate</STRONG> method returns the date of a revision.  The returned date format
is the same as the localtime format.  When called as a scalar, it returns the 
system date number.  If called is list context, the list
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) is returned.</P>
<PRE>
    # scalar mode
    $scalar_date = $obj-&gt;revdate;
    print &quot;Scalar date number = $scalar_date\n&quot;;
    $date_str = localtime($scalar_date);
    print &quot;Scalar date string = $date_str\n&quot;;</PRE>
<PRE>
    # list mode
    @list_date = $obj-&gt;revdate;
    print &quot;List date = @list_date\n&quot;;</PRE>
<P>The <STRONG>dates</STRONG> method returns a hash of revision dates, keyed on revision.  The
hash values are system date numbers.  When called in scalar mode, the method
returns the most recent revision date.</P>
<PRE>
    # list mode
    %DatesHash = obj-&gt;dates;
    @dates_list = sort {$b&lt;=&gt;$a} values %DatesHash;
    $MostRecent = $dates_list[0];</PRE>
<PRE>
    # scalar mode
    $most_recent = $obj-&gt;dates;
    print &quot;Most recent date = $most_recent\n&quot;;
    $most_recent_str = localtime($most_recent);
    print &quot;Most recent date string = $most_recent_str\n&quot;;</PRE>
<P>The <STRONG>symrev</STRONG> method returns the revision against which a specified symbol was
defined. If the symbol was not defined against any version of this file, 0 is
returned.</P>
<PRE>
    # gets revision that has 'MY_SYMBOL' defined against it
    $rev = $obj-&gt;symrev('MY_SYMBOL');</PRE>
<P>The <STRONG>daterev</STRONG> method returns revisions which were created before a specified
date.  Method may take one or six arguments.  If one arguments is passed, then
the argument is a date number.  If six arguments are passed, then they represent
a date string.</P>
<PRE>
    # one argument, date number
    # gets revisions created before Sun Sep  6 22:23:47 1998
    @revs = $obj-&gt;daterev(841436420);</PRE>
<PRE>
    # six argument
    # gets revisions created before 25th June 1998 16:45:30
    @revs = $obj-&gt;daterev(1998, 6, 25, 16, 45, 30);</PRE>
<P>The <STRONG>comments</STRONG> method returns a hash of revision comments, keyed on revision.
A key value of 0 returns the description.</P>
<PRE>
    %comments = $obj-&gt;comments;
    $description = $comments{0};
    $comment_1_3 = $comments{'1.3'};</PRE>
<P>
<H2><A NAME="rcs system methods">RCS SYSTEM METHODS</A></H2>
<P>These methods invoke the RCS system utilities.</P>
<P>The <STRONG>ci</STRONG> method calls the RCS ci program.</P>
<PRE>
    # check in, and then check out in unlocked state
    $obj-&gt;ci('-u');</PRE>
<P>The <STRONG>co</STRONG> method calls the RCS co program.</P>
<PRE>
    # check out in locked state
    $obj-&gt;co('-l');</PRE>
<P>The <STRONG>rcs</STRONG> method calls the RCS rcs program.</P>
<PRE>
    # lock file
    $obj-&gt;rcs('-l');</PRE>
<P>The <STRONG>rcsdiff</STRONG> 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.</P>
<P>When called without parameters, rcsdiff does a diff between the current
working file, and the last revision checked in.</P>
<PRE>
    # call in list context
    @diff_output = $obj-&gt;rcsdiff;</PRE>
<PRE>
    # call in scalar context
    $changed = $obj-&gt;rcsdiff;
    if ($changed) {
        print &quot;Working file has changed\n&quot;;
    }</PRE>
<P>Call rcsdiff with parameters to do a diff between any two revisions.</P>
<PRE>
    @diff_output = $obj-&gt;rcsdiff('-r1.2', '-r1.1');</PRE>
<P>The <STRONG>rlog</STRONG> method calls the RCS rlog program.  This method returns the
output of the rlog program.</P>
<PRE>
    # get complete log output
    @rlog_complete = $obj-&gt;rlog;</PRE>
<PRE>
    # called with '-h' switch outputs only header information
    @rlog_header = $obj-&gt;rlog('-h');
    print @rlog_header;</PRE>
<P>The <STRONG>rcsclean</STRONG> method calls the RCS rcsclean program.</P>
<PRE>
    # remove working file
    $obj-&gt;rcsclean;</PRE>
<P>
<HR>
<H1><A NAME="examples">EXAMPLES</A></H1>
<P>
<H2><A NAME="create access list">CREATE ACCESS LIST</A></H2>
<P>Using method <STRONG>rcs</STRONG> with the <STRONG>-a</STRONG> switch allows you to add users to
the access list of an RCS archive file.</P>
<PRE>
    use Rcs;
    $obj = Rcs-&gt;new;</PRE>
<PRE>
    $obj-&gt;rcsdir(&quot;./project_tree/archive&quot;);
    $obj-&gt;workdir(&quot;./project_tree/src&quot;);
    $obj-&gt;file(&quot;cornholio.pl&quot;);</PRE>
<P>Methos <STRONG>rcs</STRONG> invokes the RCS utility rcs with the same parameters.</P>
<PRE>
    @users = qw(beavis butthead);
    $obj-&gt;rcs(&quot;-a@users&quot;);</PRE>
<P>Calling method <STRONG>access</STRONG> returns list of users on access list.</P>
<PRE>
    $filename = $obj-&gt;file;
    @access_list = $obj-&gt;access;
    print &quot;Users @access_list are on the access list of $filename\n&quot;;</PRE>
<P>
<H2><A NAME="parse rcs archive file">PARSE RCS ARCHIVE FILE</A></H2>
<P>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.</P>
<PRE>
    use Rcs;
    Rcs-&gt;bindir('/usr/bin');
    $obj = Rcs-&gt;new;</PRE>
<P>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).</P>
<PRE>
    $obj-&gt;rcsdir(&quot;./project_tree/archive&quot;);
    $obj-&gt;workdir(&quot;./project_tree/src&quot;);
    $obj-&gt;file(&quot;cornholio.pl&quot;);</PRE>
<PRE>
    $head_rev = $obj-&gt;head;
    $locker = $obj-&gt;lock;
    $author = $obj-&gt;author;
    @access = $obj-&gt;access;
    @revisions = $obj-&gt;revisions;</PRE>
<PRE>
    $filename = $obj-&gt;file;</PRE>
<PRE>
    if ($locker) {
        print &quot;Head revision $head_rev is locked by $locker\n&quot;;
    }
    else {
        print &quot;Head revision $head_rev is unlocked\n&quot;;
    }</PRE>
<PRE>
    if (@access) {
        print &quot;\nThe following users are on the access list of file $filename\n&quot;;
        map { print &quot;User: $_\n&quot;} @access;
    }</PRE>
<PRE>
    print &quot;\nList of all revisions of $filename\n&quot;;
    foreach $rev (@revisions) {
        print &quot;Revision: $rev\n&quot;;
    }</PRE>
<P>
<H2><A NAME="checkin file">CHECK-IN FILE</A></H2>
<P>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.</P>
<PRE>
    use Rcs;
    Rcs-&gt;bindir('/usr/bin');
    Rcs-&gt;quiet(0);      # turn off quiet mode
    $obj = Rcs-&gt;new;</PRE>
<P>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).</P>
<PRE>
    $obj-&gt;file('cornholio.pl');</PRE>
<PRE>
    # Set RCS archive directory, is './RCS' by default
    $obj-&gt;rcsdir(&quot;./project_tree/archive&quot;);</PRE>
<PRE>
    # Set working directory, is '.' by default
    $obj-&gt;workdir(&quot;./project_tree/src&quot;);</PRE>
<P>Check in file using <STRONG>-u</STRONG> switch.  This will check in the file, and will then
check out the file in an unlocked state.  The <STRONG>-m</STRONG> switch is used to set the
revision comment.</P>
<P>Command:</P>
<PRE>
    $obj-&gt;ci('-u', '-mRevision Comment');</PRE>
<P>is equivalent to commands:</P>
<PRE>
    $obj-&gt;ci('-mRevision Comment');
    $obj-&gt;co;</PRE>
<P>
<H2><A NAME="checkout file">CHECK-OUT FILE</A></H2>
<P>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.</P>
<PRE>
    use Rcs;
    Rcs-&gt;bindir('/usr/bin');
    Rcs-&gt;quiet(0);      # turn off quiet mode
    $obj = Rcs-&gt;new;</PRE>
<P>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).</P>
<PRE>
    $obj-&gt;file('cornholio.pl');</PRE>
<PRE>
    # Set RCS archive directory, is './RCS' by default
    $obj-&gt;rcsdir(&quot;./project_tree/archive&quot;);</PRE>
<PRE>
    # Set working directory, is '.' by default
    $obj-&gt;workdir(&quot;./project_tree/src&quot;);</PRE>
<P>Check out file read-only:</P>
<PRE>
    $obj-&gt;co;</PRE>
<P>or check out and lock file:</P>
<PRE>
    $obj-&gt;co('-l');</PRE>
<P>
<H2><A NAME="rcsdiff">RCSDIFF</A></H2>
<P>Method <STRONG>rcsdiff</STRONG> does an diff between revisions.</P>
<PRE>
    $obj = Rcs-&gt;new;
    $obj-&gt;bindir('/usr/bin');</PRE>
<PRE>
    $obj-&gt;rcsdir(&quot;./project_tree/archive&quot;);
    $obj-&gt;workdir(&quot;./project_tree/src&quot;);
    $obj-&gt;file(&quot;cornholio.pl&quot;);</PRE>
<PRE>
    print &quot;Diff of current working file\n&quot;;
    if ($obj-&gt;rcsdiff) {       # scalar context
        print $obj-&gt;rcsdiff;   # list context
    }
    else {
       print &quot;Versions are Equal\n&quot;;
    }</PRE>
<PRE>
    print &quot;\n\nDiff of revisions 1.2 and 1.1\n&quot;;
    print $obj-&gt;rcsdiff('-r1.2', '-r1.1');</PRE>
<P>
<H2><A NAME="rcsclean">RCSCLEAN</A></H2>
<P>Method <STRONG>rcsclean</STRONG> will remove an unlocked working file.</P>
<PRE>
    use Rcs;
    Rcs-&gt;bindir('/usr/bin');
    Rcs-&gt;quiet(0);      # turn off quiet mode
    $obj = Rcs-&gt;new;</PRE>
<PRE>
    $obj-&gt;rcsdir(&quot;./project_tree/archive&quot;);
    $obj-&gt;workdir(&quot;./project_tree/src&quot;);
    $obj-&gt;file(&quot;cornholio.pl&quot;);</PRE>
<PRE>
    print &quot;Quiet mode NOT set\n&quot; unless Rcs-&gt;quiet;</PRE>
<PRE>
    $obj-&gt;rcsclean;</PRE>
<P>
<HR>
<H1><A NAME="author">AUTHOR</A></H1>
<P>Craig Freter, &lt;<EM><A HREF="mailto:craig@freter.com">craig@freter.com</A></EM>&gt;</P>
<P>
<HR>
<H1><A NAME="contributors">CONTRIBUTORS</A></H1>
<P>David Green, &lt;<EM><A HREF="mailto:greendjf@cvhp152.gpt.marconicomms.com">greendjf@cvhp152.gpt.marconicomms.com</A></EM>&gt;</P>
<P>Jamie O'Shaughnessy, &lt;<EM><A HREF="mailto:jamie@thanatar.demon.co.uk">jamie@thanatar.demon.co.uk</A></EM>&gt;</P>
<P>Raju Krishnamurthy, &lt;<EM><A HREF="mailto:raju_k@iname.com">raju_k@iname.com</A></EM>&gt;</P>
<P>
<HR>
<H1><A NAME="copyright">COPYRIGHT</A></H1>
<P>Copyright (C) 1997,1998,1999,2000,2001 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.</P>

</BODY>

</HTML>