diff options
| author | fukachan <fukachan> | 2012-02-19 10:02:09 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2012-02-19 10:02:09 +0000 |
| commit | b092f00c1d8739a9b5a54ae775705e132b88d3df (patch) | |
| tree | 1894a716929e39a9d1ccf080dd609b13a0771aac /cpan | |
| parent | 3da00fd90ee87e9367358de49f86b9d1e0edf59a (diff) | |
| download | fml8-b092f00c1d8739a9b5a54ae775705e132b88d3df.tar.gz fml8-b092f00c1d8739a9b5a54ae775705e132b88d3df.tar.bz2 fml8-b092f00c1d8739a9b5a54ae775705e132b88d3df.zip | |
remove Rcs, which is not used.
Diffstat (limited to 'cpan')
35 files changed, 0 insertions, 5463 deletions
diff --git a/cpan/dist/Rcs/ANNOUNCE b/cpan/dist/Rcs/ANNOUNCE deleted file mode 100644 index a0469142..00000000 --- a/cpan/dist/Rcs/ANNOUNCE +++ /dev/null @@ -1,35 +0,0 @@ -A recent programming project required the creation of a Revision Control -System (RCS) front end. I started with inline system calls to the RCS -utilities, and by creating multiple parsing functions to extract information -from an RCS archive file. - -I then decided to put all my functions in one place, and created Perl module -Rcs.pm. - -The next step was to change my functions into object methods, and Rcs.pm -became object oriented. - -This Perl module should be of interest to anyone creating an RCS front end. - -Here's a quick and dirty example of how to check in a file. - -use Rcs; - -$obj = Rcs->new; -$obj->file('testfile.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"); - -$obj->ci('-mRevision Comment'); - -Full documentation may be found at http://www.freter.com/perl/Rcs/Rcs.html - -If there's any interest, I would like to make Rcs.pm publicly available. -Please let me know is you have any suggestions or comments. - -Craig Freter -<craig@freter.com> diff --git a/cpan/dist/Rcs/Changes b/cpan/dist/Rcs/Changes deleted file mode 100644 index 4907cae2..00000000 --- a/cpan/dist/Rcs/Changes +++ /dev/null @@ -1,5 +0,0 @@ -Revision history for Perl extension Rcs. - -0.01 Mon Oct 19 14:09:04 1998 - - original version; created by h2xs 1.18 - diff --git a/cpan/dist/Rcs/MANIFEST b/cpan/dist/Rcs/MANIFEST deleted file mode 100644 index d770d7bb..00000000 --- a/cpan/dist/Rcs/MANIFEST +++ /dev/null @@ -1,36 +0,0 @@ -ANNOUNCE -Changes -MANIFEST -Makefile.PL -README -Rcs.html -Rcs.pm -examples/project/RCS/testfile,v -examples/project/RCS/Rcs.pm,v -examples/project/src/Rcs.pm -examples/project/src/testfile -examples/access.pl -examples/ci-tree.pl -examples/ci.pl -examples/co-tree.pl -examples/co.pl -examples/comments.pl -examples/comments2.pl -examples/daterev.pl -examples/dates.pl -examples/green.txt -examples/mark.pl -examples/parse.pl -examples/pause -examples/rcsclean.pl -examples/rcsdiff.pl -examples/revdate.pl -examples/rlog.pl -examples/symbols.pl -examples/symrev.pl -examples/test1.pl -examples/test2.pl -examples/test3.pl -examples/type -examples/unlock.pl -test.pl diff --git a/cpan/dist/Rcs/Makefile.PL b/cpan/dist/Rcs/Makefile.PL deleted file mode 100644 index 62b7f389..00000000 --- a/cpan/dist/Rcs/Makefile.PL +++ /dev/null @@ -1,7 +0,0 @@ -use ExtUtils::MakeMaker; -# See lib/ExtUtils/MakeMaker.pm for details of how to influence -# the contents of the Makefile that is written. -WriteMakefile( - 'NAME' => 'Rcs', - 'VERSION_FROM' => 'Rcs.pm', # finds $VERSION -); diff --git a/cpan/dist/Rcs/README b/cpan/dist/Rcs/README deleted file mode 100644 index c4aa6b2c..00000000 --- a/cpan/dist/Rcs/README +++ /dev/null @@ -1,30 +0,0 @@ -This is Perl Object Class Rcs.pm 0.09, a front-end to Revision Contron System (RCS) -Utilities. - -New in Version 0.07: -NT port by Jamie O'Shaughnessy, <jamie@thanatar.demon.co.uk> -Added methods 'daterev', 'symrev', and 'symbols' contributed by Jamie O'Shaughnessy. -Added method 'comments'. - -New in Version 0.08: -Fixed bug parsing comments. Bug found by David Green <greendjf@cvhp152.gpt.co.uk> -Modified daterev method to accept 1 or 6 arguments. - -New in Version 0.09: -Fixed bug parsing comments. Bug found by David Green <greendjf@cvhp152.gpt.co.uk> - -Install Rcs.pm as you would any Perl 5 module: - - perl Makefile.PL - make - make install - -The documentation is contained in Rcs.pm in pod format. The man pages -will install automatically, or may be extracted manually by: - - pod2man Rcs.pm > Rcs.man - -Please let me know is you have any suggestions or comments. - -Craig Freter -<craig@freter.com> diff --git a/cpan/dist/Rcs/Rcs.html b/cpan/dist/Rcs/Rcs.html deleted file mode 100644 index c576665c..00000000 --- a/cpan/dist/Rcs/Rcs.html +++ /dev/null @@ -1,658 +0,0 @@ -<HTML> -<HEAD> -<TITLE>Rcs - Perl Object Class for Revision Control System.</TITLE> -<LINK REV="made" HREF="mailto:freter@postal.pcy.mci.net"> -</HEAD> - -<BODY> - -<!-- INDEX BEGIN --> - -<UL> - - <LI><A HREF="#NAME">NAME</A> - <LI><A HREF="#SYNOPSIS">SYNOPSIS</A> - <LI><A HREF="#DESCRIPTION">DESCRIPTION</A> - <UL> - - <LI><A HREF="#OBJECT_CONSTRUCTOR">OBJECT CONSTRUCTOR</A> - <LI><A HREF="#CLASS_METHODS">CLASS METHODS</A> - <LI><A HREF="#OBJECT_ATTRIBUTE_METHODS">OBJECT ATTRIBUTE METHODS</A> - <LI><A HREF="#RCS_PARSE_METHODS">RCS PARSE METHODS</A> - <LI><A HREF="#RCS_SYSTEM_METHODS">RCS SYSTEM METHODS</A> - </UL> - - <LI><A HREF="#EXAMPLES">EXAMPLES</A> - <UL> - - <LI><A HREF="#CREATE_ACCESS_LIST">CREATE ACCESS LIST</A> - <LI><A HREF="#PARSE_RCS_ARCHIVE_FILE">PARSE RCS ARCHIVE FILE</A> - <LI><A HREF="#CHECK_IN_FILE">CHECK-IN FILE</A> - <LI><A HREF="#CHECK_OUT_FILE">CHECK-OUT FILE</A> - <LI><A HREF="#RCSDIFF">RCSDIFF</A> - <LI><A HREF="#RCSCLEAN">RCSCLEAN</A> - </UL> - - <LI><A HREF="#AUTHOR">AUTHOR</A> - <LI><A HREF="#CONTRIBUTORS">CONTRIBUTORS</A> - <LI><A HREF="#COPYRIGHT">COPYRIGHT</A> -</UL> -<!-- INDEX END --> - -<HR> -<P> -<H1><A NAME="NAME">NAME</A></H1> -<P> -Rcs - Perl Object Class for Revision Control System (RCS). - -<P> -<HR> -<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1> -<P> -<PRE> use Rcs; -</PRE> -<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> -<HR> -<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->new; -</PRE> -<P> -<PRE> # called as object method - $newobj = $obj->new; -</PRE> -<P> -<HR> -<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> -The <STRONG>arcext</STRONG> method sets the RCS archive extension, which is ',v' by default. - -<P> -<PRE> # set/unset RCS archive extension - Rcs->arcext(''); # set no archive extension - Rcs->arcext(',v'); # set archive extension to ',v' - $arc_ext = Rcs->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->bindir('/usr/bin'); -</PRE> -<P> -<PRE> # access RCS bin directory - $bin_dir = Rcs->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->quiet(0); # unset quiet mode - Rcs->quiet(1); # set quiet mode -</PRE> -<P> -<PRE> # access RCS quiet mode - $quiet_mode = Rcs->quiet; -</PRE> -<P> -These methods may also be called as object methods. - -<P> -<PRE> $obj->arcext(''); - $obj->bindir('/usr/bin'); - $obj->quiet(0); -</PRE> -<P> -<HR> -<H2><A NAME="OBJECT_ATTRIBUTE_METHODS">OBJECT ATTRIBUTE METHODS</A></H2> -<P> -These methods set the attributes of the RCS object. - -<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->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->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->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->rcsdir('/usr/local/archive'); -</PRE> -<P> -<HR> -<H2><A NAME="RCS_PARSE_METHODS">RCS PARSE METHODS</A></H2> -<P> -This class provides methods to directly parse the RCS archive file. - -<P> -The <STRONG>access</STRONG> method returns a list of all user on the access list. - -<P> -<PRE> @access_list = $obj->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->author('1.3'); -</PRE> -<P> -<PRE> # returns the authos of the head revision - $author = $obj->author; -</PRE> -<P> -The <STRONG>head</STRONG> method returns the head revision. - -<P> -<PRE> $head = $obj->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. - -<P> -<PRE> # returns locker of revision '1.3' - $locker = $obj->lock('1.3'); -</PRE> -<P> -<PRE> # returns locker of head revision - $locker = $obj->lock; -</PRE> -<P> -The <STRONG>revisions</STRONG> method returns a list of all revisions of archive file. - -<P> -<PRE> @revisions = $obj->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->state('1.3'); -</PRE> -<P> -<PRE> # returns state of head revision - $state = $obj->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->symbol('1.3'); -</PRE> -<P> -<PRE> # list context, returns all symbols associated with head revision - @symbols = $obj->symbol; -</PRE> -<P> -<PRE> # scalar context, returns last symbol associated with revision 1.3 - $symbol = $obj->symbol('1.3'); -</PRE> -<P> -<PRE> # scalar context, returns last symbol associated with head revision - $symbol = $obj->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->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->revdate; - print "Scalar date number = $scalar_date\n"; - $date_str = localtime($scalar_date); - print "Scalar date string = $date_str\n"; -</PRE> -<P> -<PRE> # list mode - @list_date = $obj->revdate; - print "List date = @list_date\n"; -</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->dates; - @dates_list = sort {$b<=>$a} values %DatesHash; - $MostRecent = $dates_list[0]; -</PRE> -<P> -<PRE> # scalar mode - $most_recent = $obj->dates; - print "Most recent date = $most_recent\n"; - $most_recent_str = localtime($most_recent); - print "Most recent date string = $most_recent_str\n"; -</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->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->daterev(841436420); -</PRE> -<P> -<PRE> # six argument - # gets revisions created before 25th June 1998 16:45:30 - @revs = $obj->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->comments; - $description = $comments{0}; - $comment_1_3 = $comments{'1.3'}; -</PRE> -<P> -<HR> -<H2><A NAME="RCS_SYSTEM_METHODS">RCS SYSTEM METHODS</A></H2> -<P> -These methods invoke the RCS system utilities. - -<P> -The <STRONG>ci</STRONG> method calls the RCS ci program. - -<P> -<PRE> # check in, and then check out in unlocked state - $obj->ci('-u'); -</PRE> -<P> -The <STRONG>co</STRONG> method calls the RCS co program. - -<P> -<PRE> # check out in locked state - $obj->co('-l'); -</PRE> -<P> -The <STRONG>rcs</STRONG> method calls the RCS rcs program. - -<P> -<PRE> # lock file - $obj->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> -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->rcsdiff; -</PRE> -<P> -<PRE> # call in scalar context - $changed = $obj->rcsdiff; - if ($changed) { - print "Working file has changed\n"; - } -</PRE> -<P> -Call rcsdiff with parameters to do a diff between any two revisions. - -<P> -<PRE> @diff_output = $obj->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->rlog; -</PRE> -<P> -<PRE> # called with '-h' switch outputs only header information - @rlog_header = $obj->rlog('-h'); - print @rlog_header; -</PRE> -<P> -The <STRONG>rcsclean</STRONG> method calls the RCS rcsclean program. - -<P> -<PRE> # remove working file - $obj->rcsclean; -</PRE> -<P> -<HR> -<H1><A NAME="EXAMPLES">EXAMPLES</A></H1> -<P> -<HR> -<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->new; -</PRE> -<P> -<PRE> $obj->rcsdir("./project_tree/archive"); - $obj->workdir("./project_tree/src"); - $obj->file("cornholio.pl"); -</PRE> -<P> -Methos <STRONG>rcs</STRONG> invokes the RCS utility rcs with the same parameters. - -<P> -<PRE> @users = qw(beavis butthead); - $obj->rcs("-a@users"); -</PRE> -<P> -Calling method <STRONG>access</STRONG> returns list of users on access list. - -<P> -<PRE> $filename = $obj->file; - @access_list = $obj->access; - print "Users @access_list are on the access list of $filename\n"; -</PRE> -<P> -<HR> -<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->bindir('/usr/bin'); - $obj = Rcs->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->rcsdir("./project_tree/archive"); - $obj->workdir("./project_tree/src"); - $obj->file("cornholio.pl"); -</PRE> -<P> -<PRE> $head_rev = $obj->head; - $locker = $obj->lock; - $author = $obj->author; - @access = $obj->access; - @revisions = $obj->revisions; -</PRE> -<P> -<PRE> $filename = $obj->file; -</PRE> -<P> -<PRE> if ($locker) { - print "Head revision $head_rev is locked by $locker\n"; - } - else { - print "Head revision $head_rev is unlocked\n"; - } -</PRE> -<P> -<PRE> if (@access) { - print "\nThe following users are on the access list of file $filename\n"; - map { print "User: $_\n"} @access; - } -</PRE> -<P> -<PRE> print "\nList of all revisions of $filename\n"; - foreach $rev (@revisions) { - print "Revision: $rev\n"; - } -</PRE> -<P> -<HR> -<H2><A NAME="CHECK_IN_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->bindir('/usr/bin'); - Rcs->quiet(0); # turn off quiet mode - $obj = Rcs->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->file('cornholio.pl'); -</PRE> -<P> -<PRE> # Set RCS archive directory, is './RCS' by default - $obj->rcsdir("./project_tree/archive"); -</PRE> -<P> -<PRE> # Set working directory, is '.' by default - $obj->workdir("./project_tree/src"); -</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> -Command: - -<P> -<PRE> $obj->ci('-u', '-mRevision Comment'); -</PRE> -<P> -is equivalent to commands: - -<P> -<PRE> $obj->ci('-mRevision Comment'); - $obj->co; -</PRE> -<P> -<HR> -<H2><A NAME="CHECK_OUT_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->bindir('/usr/bin'); - Rcs->quiet(0); # turn off quiet mode - $obj = Rcs->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->file('cornholio.pl'); -</PRE> -<P> -<PRE> # Set RCS archive directory, is './RCS' by default - $obj->rcsdir("./project_tree/archive"); -</PRE> -<P> -<PRE> # Set working directory, is '.' by default - $obj->workdir("./project_tree/src"); -</PRE> -<P> -Check out file read-only: - -<P> -<PRE> $obj->co; -</PRE> -<P> -or check out and lock file: - -<P> -<PRE> $obj->co('-l'); -</PRE> -<P> -<HR> -<H2><A NAME="RCSDIFF">RCSDIFF</A></H2> -<P> -Method <STRONG>rcsdiff</STRONG> does an diff between revisions. - -<P> -<PRE> $obj = Rcs->new; - $obj->bindir('/usr/bin'); -</PRE> -<P> -<PRE> $obj->rcsdir("./project_tree/archive"); - $obj->workdir("./project_tree/src"); - $obj->file("cornholio.pl"); -</PRE> -<P> -<PRE> print "Diff of current working file\n"; - if ($obj->rcsdiff) { # scalar context - print $obj->rcsdiff; # list context - } - else { - print "Versions are Equal\n"; - } -</PRE> -<P> -<PRE> print "\n\nDiff of revisions 1.2 and 1.1\n"; - print $obj->rcsdiff('-r1.2', '-r1.1'); -</PRE> -<P> -<HR> -<H2><A NAME="RCSCLEAN">RCSCLEAN</A></H2> -<P> -Method <STRONG>rcsclean</STRONG> will remove an unlocked working file. - -<P> -<PRE> use Rcs; - Rcs->bindir('/usr/bin'); - Rcs->quiet(0); # turn off quiet mode - $obj = Rcs->new; -</PRE> -<P> -<PRE> $obj->rcsdir("./project_tree/archive"); - $obj->workdir("./project_tree/src"); - $obj->file("cornholio.pl"); -</PRE> -<P> -<PRE> print "Quiet mode NOT set\n" unless Rcs->quiet; -</PRE> -<P> -<PRE> $obj->rcsclean; -</PRE> -<P> -<HR> -<H1><A NAME="AUTHOR">AUTHOR</A></H1> -<P> -Craig Freter, <<EM>craig@freter.com</EM>> - - - -<P> -<HR> -<H1><A NAME="CONTRIBUTORS">CONTRIBUTORS</A></H1> -<P> -David Green, <<EM>greendjf@cvhp152.gpt.co.uk</EM>> - - - -<P> -Jamie O'Shaughnessy, <<EM>jamie@thanatar.demon.co.uk</EM>> - - - -<P> -<HR> -<H1><A NAME="COPYRIGHT">COPYRIGHT</A></H1> -<P> -Copyright (C) 1997,1998 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. - -</BODY> - -</HTML> diff --git a/cpan/dist/Rcs/Rcs.pm b/cpan/dist/Rcs/Rcs.pm deleted file mode 100644 index 1c6e2f4b..00000000 --- a/cpan/dist/Rcs/Rcs.pm +++ /dev/null @@ -1,1343 +0,0 @@ -package Rcs; -require 5.001; -use strict; -use Carp; -use Time::Local; -use vars qw($VERSION $revision); - -#------------------------------------------------------------------ -# global stuff -#------------------------------------------------------------------ -$VERSION = '0.09'; -$revision = '$Id: Rcs.pm,v 1.14.1.3 1998/10/19 18:04:48 freter Exp $'; -my $Dir_Sep = ($^O eq 'MSWin32') ? '\\' : '/'; -my $Exe_Ext = ($^O eq 'MSWin32') ? '.exe' : ''; -my $Rcs_Bin_Dir = '/usr/local/bin'; -my $Rcs_Dir = '.' . $Dir_Sep . 'RCS'; -my $Work_Dir = '.'; -my $Quiet = 1; # RCS quiet mode -my $Arc_Ext = ',v'; - -#------------------------------------------------------------------ -# RCS object constructor -#------------------------------------------------------------------ -sub new { - my $proto = shift; - my $class = ref($proto) || $proto; - my $self = {}; - - # provide default values for system stuff - $self->{"_BINDIR"} = \$Rcs_Bin_Dir; - $self->{"_QUIET"} = \$Quiet; - $self->{"_RCSDIR"} = \$Rcs_Dir; - $self->{"_WORKDIR"} = \$Work_Dir; - $self->{"_ARCEXT"} = \$Arc_Ext; - - $self->{FILE} = undef; - $self->{ARCFILE} = undef; - $self->{AUTHOR} = undef; - $self->{COMMENTS} = undef; - $self->{DATE} = undef; - $self->{LOCK} = undef; - $self->{ACCESS} = []; - $self->{REVISIONS} = []; - $self->{REVINFO} = undef; - $self->{STATE} = undef; - $self->{SYMBOLS} = undef; - bless($self, $class); - return $self; -} - -#------------------------------------------------------------------ -# access -# Access list of archive file. -#------------------------------------------------------------------ -sub access { - my $self = shift; - - if (not @{ $self->{ACCESS} }) { - _parse_rcs_header($self); - } - - # dereference revisions list - my @access = @{ $self->{ACCESS} }; - - return @access; -} - -#------------------------------------------------------------------ -# arcext -# Set the RCS archive file extension (default is ',v'). -#------------------------------------------------------------------ -sub arcext { - my $self = shift; - - # called as object method - if (ref $self) { - if (@_) { ${ $self->{"_ARCEXT"} } = shift }; - return ${ $self->{"_ARCEXT"} }; - } - - # called as class method - else { - if (@_) { $Arc_Ext = shift; } - return $Arc_Ext; - } -} - -#------------------------------------------------------------------ -# arcfile -# Name of RCS archive file. -# If not set then return name of working file with RCS -# extension (',v'). -#------------------------------------------------------------------ -sub arcfile { - my $self = shift; - if (@_) { $self->{ARCFILE} = shift } - return $self->{ARCFILE} || $self->{FILE} . ${ $self->{"_ARCEXT"} }; -} - -#------------------------------------------------------------------ -# author -# Return the author of an RCS revision. -# If revision is not provided, default to 'head' revision. -#------------------------------------------------------------------ -sub author { - my $self = shift; - - if (not defined $self->{AUTHOR}) { - _parse_rcs_header($self); - } - my $revision = shift || $self->{HEAD}; - - # dereference author hash - my %author_array = %{ $self->{AUTHOR} }; - - return $author_array{$revision}; -} - -#------------------------------------------------------------------ -# bindir -# Set the bin directory in which the RCS distribution programs -# reside. -#------------------------------------------------------------------ -sub bindir { - my $self = shift; - - # called as object method - if (ref $self) { - if (@_) { ${ $self->{"_BINDIR"} } = shift }; - return ${ $self->{"_BINDIR"} }; - } - - # called as class method - else { - if (@_) { $Rcs_Bin_Dir = shift }; - return $Rcs_Bin_Dir; - } -} - -#------------------------------------------------------------------ -# ci -# Execute RCS 'ci' program. -# Make archive filename same as working filename unless -# specifically set. -#------------------------------------------------------------------ -sub ci { - my $self = shift; - my @param = @_; - - my $ciprog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'ci' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $workdir = ${ $self->{"_WORKDIR"} }; - my $file = $self->{FILE}; - my $arcfile = $self->{ARCFILE} || $file; - - my $archive_file = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - my $workfile = $workdir . $Dir_Sep . $file; - push @param, $archive_file, $workfile; - unshift @param, "-q" if ${ $self->{"_QUIET"} }; # quiet mode - - # run program - croak "ci program $ciprog not found" unless -e $ciprog; - croak "ci program $ciprog not executable" unless -x $ciprog; - system($ciprog, @param) == 0 or croak "$!"; - - # re-parse RCS file and clear comments hash - _parse_rcs_header($self); - $self->{COMMENTS} = undef; -} - -#------------------------------------------------------------------ -# co -# Execute RCS 'co' program. -# Make archive filename same as working filename unless -# specifically set. -#------------------------------------------------------------------ -sub co { - my $self = shift; - my @param = @_; - - my $coprog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'co' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $workdir = ${ $self->{"_WORKDIR"} }; - my $file = $self->{FILE}; - my $arcfile = $self->{ARCFILE} || $file; - - my $archive_file = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - my $workfile = $workdir . $Dir_Sep . $file; - push @param, $archive_file, $workfile; - unshift @param, "-q" if ${ $self->{"_QUIET"} }; # quiet mode - - # run program - croak "co program $coprog not found" unless -e $coprog; - croak "co program $coprog not executable" unless -x $coprog; - system($coprog, @param) == 0 or croak "$!"; - - # re-parse RCS file and clear comments hash - _parse_rcs_header($self); - $self->{COMMENTS} = undef; -} - -#------------------------------------------------------------------ -# comments -#------------------------------------------------------------------ -sub comments { - my $self = shift; - - if (not defined $self->{COMMENTS}) { - _parse_rcs_body($self); - } - - return %{$self->{COMMENTS}}; -} - -#------------------------------------------------------------------ -# daterev -# -# Returns revisions which were created before a specified date. -# -# Method takes one or six arguments. -# -# If one argument, then argument is date number. -# -# If six arguments, then year (4 digit year), month (1-12), day -# of month (1-31), hour (0-23), minute (0-59) and second (0-59). -#------------------------------------------------------------------ -sub daterev { - - my $self = shift; - my $target_time; - - # validate arguments - unless (@_ == 1 or @_ == 6) { - croak "daterev must have either 1 or 6 arguments"; - } - - # string date passed - if (@_ == 6) { - my($year, $mon, $mday, $hour, $min, $sec) = @_; - - if($year !~ /^\d{4}$/) { - croak "year (1st param) must be 4 digit number"; - } - - $mon--; # convert to 0-11 range - $target_time = timegm($sec, $min, $hour, $mday, $mon, $year); - } - - # system date passed - else { - $target_time = shift; - - if ($target_time !~ /^\d+$/) { - croak "system date must be an integer"; - } - } - - if (not defined $self->{DATE}) { - _parse_rcs_header($self); - } - - my @revisions = (); - my %dates; - my %dates_hash = %{$self->{DATE}}; - - my $revision; - foreach $revision (keys %dates_hash) { - my $date = $dates_hash{$revision}; - $dates{$date}{$revision} = 1; - } - - my $date; - foreach $date (reverse sort keys %dates) { - foreach $revision (keys %{ $dates{$date} }) { - push @revisions, $revision if $date <= $target_time; - } - } - - return wantarray ? @revisions : $revisions[0]; -} - -#------------------------------------------------------------------ -# dates -# Return a hash of revision dates, keyed on revision, when called -# in list mode. -# Return the most recent date when called in scalar mode. -# -# RCS stores dates in GMT. -# The date values are system dates. -#------------------------------------------------------------------ -sub dates { - my $self = shift; - - if (not defined $self->{DATE}) { - _parse_rcs_header($self); - } - - my %DatesHash = %{$self->{DATE}}; - my @dates_list = sort {$b<=>$a} values %DatesHash; - my $MostRecent = $dates_list[0]; - - return wantarray ? %DatesHash : $MostRecent; -} - -#------------------------------------------------------------------ -# file -# Name of working file. -#------------------------------------------------------------------ -sub file { - my $self = shift; - if (@_) { $self->{FILE} = shift } - return $self->{FILE}; -} - -#------------------------------------------------------------------ -# head -# Return the head revision. -#------------------------------------------------------------------ -sub head { - my $self = shift; - - if (not defined $self->{HEAD}) { - _parse_rcs_header($self); - } - return $self->{HEAD}; -} - -#------------------------------------------------------------------ -# lock -# Return user who has file locked. -#------------------------------------------------------------------ -sub lock { - my $self = shift; - - if (not defined $self->{LOCK}) { - _parse_rcs_header($self); - } - return $self->{LOCK}; -} - -#------------------------------------------------------------------ -# quiet -# Set or un-set RCS quiet mode. -#------------------------------------------------------------------ -sub quiet { - my $self = shift; - - # called as object method - if (ref $self) { - - # set/un-set quiet mode - if (@_) { - my $mode = shift; - croak "Passed parameter must be either '0' or '1'" - unless $mode == 0 or $mode == 1; - ${ $self->{"_QUIET"} } = $mode; - return ${ $self->{"_QUIET"} }; - } - - # access quiet mode - else { - return ${ $self->{"_QUIET"} }; - } - } - - # called as class method - else { - - # set/un-set quiet mode - if (@_) { - my $mode = shift; - croak "Passed parameter must be either '0' or '1'" - unless $mode == 0 or $mode == 1; - $Quiet = $mode; - return $Quiet; - } - - # access quiet mode - else { - return $Quiet; - } - } -} - -#------------------------------------------------------------------ -# rcs -# Execute RCS 'rcs' program. -# Make archive filename same as working filename unless -# specifically set. -#------------------------------------------------------------------ -sub rcs { - my $self = shift; - my @param = @_; - - my $rcsprog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'rcs' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $workdir = ${ $self->{"_WORKDIR"} }; - my $file = $self->{FILE}; - my $arcfile = $self->{ARCFILE} || $file; - - my $archive_file = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - my $workfile = $workdir . $Dir_Sep . $file; - push @param, $archive_file, $workfile; - unshift @param, "-q" if ${ $self->{"_QUIET"} }; # quiet mode - - # run program - croak "rcs program $rcsprog not found" unless -e $rcsprog; - croak "rcs program $rcsprog not executable" unless -x $rcsprog; - system($rcsprog, @param) == 0 or croak "$?"; - - # re-parse RCS file and clear comments hash - _parse_rcs_header($self); - $self->{COMMENTS} = undef; -} - -#------------------------------------------------------------------ -# rcsclean -# Execute RCS 'rcsclean' program. -#------------------------------------------------------------------ -sub rcsclean { - my $self = shift; - my @param = @_; - - my $rcscleanprog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'rcsclean' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $workdir = ${ $self->{"_WORKDIR"} }; - my $file = $self->{FILE}; - my $arcfile = $self->{ARCFILE} || $file; - - my $archive_file = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - my $workfile = $workdir . $Dir_Sep . $file; - push @param, $archive_file, $workfile; - - # run program - croak "rcsclean program $rcscleanprog not found" unless -e $rcscleanprog; - croak "rcsclean program $rcscleanprog not executable" unless -x $rcscleanprog; - system($rcscleanprog, @param) == 0 or croak "$?"; - - # re-parse RCS file and clear comments hash - _parse_rcs_header($self); - $self->{COMMENTS} = undef; -} - -#------------------------------------------------------------------ -# rcsdiff -# Execute RCS 'rcsdiff' program. -# Calling in list context returns the output of rcsdiff, while -# calling in scalar context returns the return status of the -# rcsdiff program. -#------------------------------------------------------------------ -sub rcsdiff { - my $self = shift; - my @param = @_; - - my $rcsdiff_prog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'rcsdiff' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $arcfile = $self->{ARCFILE} || $self->{FILE}; - $arcfile = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - my $workfile = $self->workdir . $Dir_Sep . $self->file; - - # un-taint parameter string - unshift @param, "-q" if ${ $self->{"_QUIET"} }; # quiet mode - my $param_str = join(' ', @param); - $param_str =~ s/([\w-]+)/$1/g; - - croak "rcsdiff program $rcsdiff_prog not found" unless -e $rcsdiff_prog; - croak "rcsdiff program $rcsdiff_prog not executable" unless -x $rcsdiff_prog; - open(DIFF, "$rcsdiff_prog $param_str $arcfile $workfile |"); - my @diff_output = <DIFF>; - - # rcsdiff returns exit status 0 for no differences, 1 for differences, - # and 2 for error condition. - close DIFF; - my $status = $?; - croak "$rcsdiff_prog failed" if $status == 2; - return wantarray ? @diff_output : $status; -} - -#------------------------------------------------------------------ -# rcsdir -# Location of 'RCS' archive directory. -#------------------------------------------------------------------ -sub rcsdir { - my $self = shift; - - # called as object method - if (ref $self) { - if (@_) { ${ $self->{"_RCSDIR"} } = shift } - return ${ $self->{"_RCSDIR"} }; - } - - # called as class method - else { - if (@_) { $Rcs_Dir = shift } - return $Rcs_Dir; - } -} - -#------------------------------------------------------------------ -# revdate -# Return the revision date of an RCS revision. -# If revision is not provided, default to 'head' revision. -# -# RCS stores dates in GMT. This method will return dates relative -# to the local time zone. -#------------------------------------------------------------------ -sub revdate { - my $self = shift; - - if (not defined $self->{DATE}) { - _parse_rcs_header($self); - } - my $revision = shift || $self->{HEAD}; - - # dereference date hash - my %date_array = %{ $self->{DATE} }; - my $date_str = $date_array{$revision}; - - return wantarray ? localtime($date_str) : $date_str; -} - -#------------------------------------------------------------------ -# revisions -#------------------------------------------------------------------ -sub revisions { - my $self = shift; - - if (not @{ $self->{REVISIONS} }) { - _parse_rcs_header($self); - } - - # dereference revisions list - my @revisions = @{ $self->{REVISIONS} }; - - @revisions; -} - -#------------------------------------------------------------------ -# rlog -# Execute RCS 'rlog' program. -# Make archive filename same as working filename unless -# specifically set. -#------------------------------------------------------------------ -sub rlog { - my $self = shift; - my @param = @_; - - my $rlogprog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'rlog' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $arcfile = $self->{ARCFILE} || $self->{FILE}; - - # un-taint parameter string - my $param_str = join(' ', @param); - $param_str =~ s/([\w-]+)/$1/g; - - my $archive_file = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - croak "rlog program $rlogprog not found" unless -e $rlogprog; - croak "rlog program $rlogprog not executable" unless -x $rlogprog; - open(RLOG, "$rlogprog $param_str $archive_file |"); - - my @logoutput = <RLOG>; - close RLOG; - croak "$rlogprog failed" if $?; - @logoutput; -} - -#------------------------------------------------------------------ -# state -# If revision is not provided, default to 'head' revision -#------------------------------------------------------------------ -sub state { - my $self = shift; - - if (not defined $self->{STATE}) { - _parse_rcs_header($self); - } - my $revision = shift || $self->{HEAD}; - - # dereference author hash - my %state_array = %{ $self->{STATE} }; - - return $state_array{$revision}; -} - -#------------------------------------------------------------------ -# symbol -# If revision is not provided, default to 'head' revision -#------------------------------------------------------------------ -sub symbol { - my $self = shift; - - if (not defined $self->{SYMBOLS}) { - _parse_rcs_header($self); - } - my $revision = shift || $self->{HEAD}; - - # dereference symbols hash - my %sym_array = %{ $self->{SYMBOLS} }; - - return '' if not defined $sym_array{$revision}; - - my @symbols = @{ $sym_array{$revision} }; - - # return only first array element if user wants scalar - return wantarray ? @symbols : $symbols[0]; -} - -#------------------------------------------------------------------ -# symbols -# Returns hash of all revisions keyed on symbol defined against file. -#------------------------------------------------------------------ -sub symbols { - my $self = shift; - - if(not defined $self->{SYMBOLS}) { - _parse_rcs_header($self); - } - - my %symbols; - - # loop through each revision - my $rev; - foreach $rev (@{ $self->{REVISIONS} }) { - my $sym; - foreach $sym (@{ $self->{SYMBOLS}->{$rev} }) { - $symbols{$sym} = $rev; - } - } - return %symbols; -} - -#------------------------------------------------------------------ -# symrev -# 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. -#------------------------------------------------------------------ -sub symrev { - my $self = shift; - my $sym = shift; - if(! defined $sym) { - croak "You must supply a symbol to symrev"; - } - - if (not defined $self->{SYMBOLS}) { - _parse_rcs_header($self); - } - - my $ret_rev = 0; - my %symbols; - - # loop through each revision - my $rev; - REV_LOOP: - foreach $rev (@{ $self->{REVISIONS} }) { - # loop through each symbol defined against - # this revision - my $s; - foreach $s (@{ $self->{SYMBOLS}->{$rev} }) { - - # store each revision matching the pattern - if (wantarray) { - $symbols{$s} = $rev if $s =~ /$sym/; - } - - # if it's the one we're looking for, we can - # quit as we've found the revision we want - else { - if($s eq $sym) { - $ret_rev = $rev; - last REV_LOOP; - } - } - } - } - - return wantarray ? %symbols : $ret_rev; -} - -#------------------------------------------------------------------ -# workdir -# Location of working directory. -#------------------------------------------------------------------ -sub workdir { - my $self = shift; - - # called as object method - if (ref $self) { - if (@_) { ${ $self->{"_WORKDIR"} } = shift } - return ${ $self->{"_WORKDIR"} }; - } - - # called as class method - else { - if (@_) { $Work_Dir = shift } - return $Work_Dir; - } -} - -#------------------------------------------------------------------ -# _parse_rcs_body -# Private function -#------------------------------------------------------------------ -sub _parse_rcs_body { - - my $self = shift; - local $_; - - my %comments; - - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $file = $self->{FILE}; - my $rcs_file = $rcsdir . $Dir_Sep . $file . ${ $self->{"_ARCEXT"} }; - - # parse RCS archive file - open RCS_FILE, $rcs_file or croak "Unable to open $rcs_file"; - - # skip header info and get description - DESC: while (<RCS_FILE>) { - if (/^desc$/) { - $comments{0} = ''; - $_ = <RCS_FILE>; # read first line - s/^\@//; # remove leading '@' - while (1) { - last DESC if /^\@$/; - s/\@\@/\@/g; # RCS replaces single '@' with '@@' - $comments{0} .= $_; - $_ = <RCS_FILE>; - } - } - } - - # parse revision comments - my $revision; - REVISION: while (<RCS_FILE>) { - if (/^[\d\.]+$/) { - chomp($revision = $_); - $_ = <RCS_FILE>; - if (/^log$/) { - $comments{$revision} = ''; - $_ = <RCS_FILE>; # read first line - s/^\@//; # remove leading '@' - while (1) { - next REVISION if /^\@$/; - s/\@\@/\@/g; # RCS replaces single '@' with '@@' - $comments{$revision} .= $_; - $_ = <RCS_FILE>; - } - } - } - } - - # loop through 'text' section to avoid capturing bogus info - continue { - if (/^text$/) { # 'text' tag should always be there, but check anyway - while (<RCS_FILE>) { - s/\@\@//g; # RCS replaces single '@' with '@@' - last if /\@$/ - } - } - } - - close RCS_FILE; - $self->{COMMENTS} = \%comments; -} - -#------------------------------------------------------------------ -# _parse_rcs_header -# Private function -# Directly parse the RCS archive file. -#------------------------------------------------------------------ -sub _parse_rcs_header { - - my $self = shift; - local $_; - - my ($head, $lock); - my (@access_list, @revisions); - my (%author, %date, %state, %symbols); - - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $file = $self->{FILE}; - my $rcs_file = $rcsdir . $Dir_Sep . $file . ${ $self->{"_ARCEXT"} }; - - # parse RCS archive file - open RCS_FILE, $rcs_file - or croak "Unable to open $rcs_file"; - while (<RCS_FILE>) { - next if /^\s*$/; # skip blank lines - last if /^desc$/; # end of header info - - # get head revision - if (/^head\s/) { - ($head) = /^head\s+(.*?);$/; - next; - } - - # get access list - if (/^access$/) { - while (<RCS_FILE>) { - chomp; - s/\s//g; # remove all whitespace - push @access_list, (split(/;/))[0]; - last if /;$/; - } - next; - } - - # get locker - # get symbols - if (/^symbols$/) { - while (<RCS_FILE>) { - chomp; - s/\s//g; # remove all whitespace - my ($sym, $rev) = split(/:/); - $rev =~ s/;$//; - push @{ $symbols{$rev} }, $sym; - last if /;$/; - } - next; - } - - # get locker - if (/^locks/) { - - # file not locked - if (/strict/) { - $lock = ''; - next; - } - - # get user who has file locked - my $next_line = <RCS_FILE>; # read next line - ($lock) = $next_line =~ m/^\s*(\w+):/; - next; - } - - # get all revisions - if (/^\d+\.\d+/) { - chomp; - push @revisions, $_; - - # get author, state and date of each revision - my $next_line = <RCS_FILE>; - chop(my $author = (split(/\s+/, $next_line))[3]); - chop(my $state = (split(/\s+/, $next_line))[5]); - chop(my $date = (split(/\s+/, $next_line))[1]); - - # store date as date number - my ($year, $mon, $mday, $hour, $min, $sec) = split(/\./, $date); - $mon--; # convert to 0-11 range - my @date = ($sec,$min,$hour,$mday,$mon,$year); - - # store value in hash using revision as key - $author{$_} = $author; - $state{$_} = $state; - $date{$_} = timegm(@date); - } - } - close RCS_FILE; - - $self->{HEAD} = $head; - $self->{LOCK} = $lock; - $self->{ACCESS} = \@access_list; - $self->{REVISIONS} = \@revisions; - $self->{AUTHOR} = \%author; - $self->{DATE} = \%date; - $self->{STATE} = \%state; - $self->{SYMBOLS} = \%symbols; -} - -1; - -__END__ - -=head1 NAME - -Rcs - Perl Object Class for Revision Control System (RCS). - -=head1 SYNOPSIS - - use Rcs; - -=head1 DESCRIPTION - -This Perl module provides an object oriented interface to access -B<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. - -=head2 OBJECT CONSTRUCTOR - -The B<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; - -=head2 CLASS METHODS - -Besides the object constructor, there are three class methods provided -which effect any newly created objects. - -The B<arcext> method sets the RCS archive extension, which is ',v' by -default. - - # set/unset RCS archive extension - Rcs->arcext(''); # set no archive extension - Rcs->arcext(',v'); # set archive extension to ',v' - $arc_ext = Rcs->arcext(); # get current archive extension - -The B<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 B<quiet> method sets/unsets the quiet mode for the RCS executables. -Quiet mode is set by 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->arcext(''); - $obj->bindir('/usr/bin'); - $obj->quiet(0); - -=head2 OBJECT ATTRIBUTE METHODS - -These methods set the attributes of the RCS object. - -The B<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 B<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 -RCS archive extension (default ',v') is automatically added to the filename. - - $obj->arcfile('principle_mcvicker.pl'); - -The B<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 B<rcsdir> methods set the path of the RCS archive directory. If not -specified, default path is './RCS'. - - $obj->rcsdir('/usr/local/archive'); - -=head2 RCS PARSE METHODS - -This class provides methods to directly parse the RCS archive file. - -The B<access> method returns a list of all user on the access list. - - @access_list = $obj->access; - -The B<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 B<head> method returns the head revision. - - $head = $obj->head; - -The B<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 B<revisions> method returns a list of all revisions of archive file. - - @revisions = $obj->revisions; - -The B<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 B<symbol> method returns the symbol(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 a 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 B<symbols> method returns a hash, keyed by symbol, of all of the revisions -associated with the file. - - %symbols = $obj->symbols; - foreach $sym (keys %symbols) { - $rev = $symbols{$sym}; - } - -The B<revdate> 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. - - # scalar mode - $scalar_date = $obj->revdate; - print "Scalar date number = $scalar_date\n"; - $date_str = localtime($scalar_date); - print "Scalar date string = $date_str\n"; - - # list mode - @list_date = $obj->revdate; - print "List date = @list_date\n"; - -The B<dates> 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. - - # list mode - %DatesHash = obj->dates; - @dates_list = sort {$b<=>$a} values %DatesHash; - $MostRecent = $dates_list[0]; - - # scalar mode - $most_recent = $obj->dates; - print "Most recent date = $most_recent\n"; - $most_recent_str = localtime($most_recent); - print "Most recent date string = $most_recent_str\n"; - -The B<symrev> 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. - - # gets revision that has 'MY_SYMBOL' defined against it - $rev = $obj->symrev('MY_SYMBOL'); - -The B<daterev> 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. - - # one argument, date number - # gets revisions created before Sun Sep 6 22:23:47 1998 - @revs = $obj->daterev(841436420); - - # six argument - # gets revisions created before 25th June 1998 16:45:30 - @revs = $obj->daterev(1998, 6, 25, 16, 45, 30); - -The B<comments> method returns a hash of revision comments, keyed on revision. -A key value of 0 returns the description. - - %comments = $obj->comments; - $description = $comments{0}; - $comment_1_3 = $comments{'1.3'}; - -=head2 RCS SYSTEM METHODS - -These methods invoke the RCS system utilities. - -The B<ci> method calls the RCS ci program. - - # check in, and then check out in unlocked state - $obj->ci('-u'); - -The B<co> method calls the RCS co program. - - # check out in locked state - $obj->co('-l'); - -The B<rcs> method calls the RCS rcs program. - - # lock file - $obj->rcs('-l'); - -The B<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 B<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 B<rcsclean> method calls the RCS rcsclean program. - - # remove working file - $obj->rcsclean; - - -=head1 EXAMPLES - -=head2 CREATE ACCESS LIST - -Using method B<rcs> with the B<-a> switch allows you to add users to -the access list of an RCS archive file. - - use Rcs; - $obj = Rcs->new; - - $obj->rcsdir("./project_tree/archive"); - $obj->workdir("./project_tree/src"); - $obj->file("cornholio.pl"); - -Methos B<rcs> invokes the RCS utility rcs with the same parameters. - - @users = qw(beavis butthead); - $obj->rcs("-a@users"); - -Calling method B<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"; - - -=head2 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 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"; - } - -=head2 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 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 B<-u> switch. This will check in the file, and will then -check out the file in an unlocked state. The B<-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; - -=head2 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 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'); - -=head2 RCSDIFF - -Method B<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'); - -=head2 RCSCLEAN - -Method B<rcsclean> will remove an unlocked working file. - - use 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; - -=head1 AUTHOR - -Craig Freter, E<lt>F<craig@freter.com>E<gt> - -=head1 CONTRIBUTORS - -David Green, E<lt>F<greendjf@cvhp152.gpt.co.uk>E<gt> - -Jamie O'Shaughnessy, E<lt>F<jamie@thanatar.demon.co.uk>E<gt> - -=head1 COPYRIGHT - -Copyright (C) 1997,1998 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. - -=cut - diff --git a/cpan/dist/Rcs/examples/access.pl b/cpan/dist/Rcs/examples/access.pl deleted file mode 100755 index 96597e5c..00000000 --- a/cpan/dist/Rcs/examples/access.pl +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# Add users to access list. -#------------------------------------------ -use strict; -use Rcs; - -Rcs->bindir('/usr/bin'); -Rcs->quiet(0); -my $obj = Rcs->new; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("testfile"); - -my @users = qw(beavis butthead); -$obj->rcs("-a@users"); - -my $filename = $obj->file; -my @access_list = $obj->access; -print "Users @access_list are on the access list of $filename\n"; diff --git a/cpan/dist/Rcs/examples/ci-tree.pl b/cpan/dist/Rcs/examples/ci-tree.pl deleted file mode 100755 index 4917ba1a..00000000 --- a/cpan/dist/Rcs/examples/ci-tree.pl +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use File::Find; -use File::Path; -use Rcs; - -Rcs->bindir("/usr/bin"); - -my $comment = shift; - -# Traverse desired filesystems - -my $tree_root = '/home/freter/tmp'; -my $rcs_path = '/RCS'; -my $src_path = '/src'; - -find(\&wanted, $tree_root . $src_path); - -exit; - -sub wanted { - my $relative_path = $File::Find::dir; - ($relative_path) =~ s{^$tree_root$src_path}{}; - print $relative_path; - print "\n"; - mkpath([$tree_root . $rcs_path . $relative_path], 1, 0755); - - return unless -f; - my $obj = Rcs->new; - $obj->file($_); - $obj->rcsdir($tree_root . $rcs_path . $relative_path); - $obj->workdir($tree_root . $src_path . $relative_path); - - # archive file exists - if (! -e $obj->rcsdir . '/' . $obj->arcfile) { - print "Initial Check-in\n"; - $obj->ci("-l", "-t-$comment"); - } - - # create archive file - else { - print "Check-in\n"; - $obj->ci("-l", "-m$comment"); - } -} diff --git a/cpan/dist/Rcs/examples/ci.pl b/cpan/dist/Rcs/examples/ci.pl deleted file mode 100755 index 7d1ae42f..00000000 --- a/cpan/dist/Rcs/examples/ci.pl +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# Check-in source file. -#------------------------------------------ -use strict; -use Rcs; - -Rcs->bindir('/usr/bin'); -Rcs->quiet(0); # turn off quiet mode -my $obj = Rcs->new; - -print "Quiet mode set\n" if Rcs->quiet; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("testfile"); - -# archive file exists -if (! -e $obj->rcsdir . '/' . $obj->arcfile) { - print "Initial Check-in\n"; - $obj->ci("-u"); -} - -# create archive file -else { - print "Check-in\n"; - $obj->ci("-l"); -} diff --git a/cpan/dist/Rcs/examples/co-tree.pl b/cpan/dist/Rcs/examples/co-tree.pl deleted file mode 100755 index bf35b4f2..00000000 --- a/cpan/dist/Rcs/examples/co-tree.pl +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use File::Find; -use File::Path; -use Rcs; - -Rcs->bindir("/usr/bin"); - -my $lock = 0; - -# Traverse desired filesystems - -my $tree_root = '/home/freter/tmp'; -my $rcs_path = '/RCS'; -my $chkpt_path = '/chkpt'; - -find(\&wanted, $tree_root . $rcs_path); - -exit; - -sub wanted { - my $relative_path = $File::Find::dir; - ($relative_path) =~ s{^$tree_root$rcs_path}{}; - print $relative_path; - print "\n"; - mkpath([$tree_root . $chkpt_path . $relative_path], 1, 0755); - - return unless -f; - my $obj = Rcs->new; - s/,v$//; - $obj->file($_); - $obj->rcsdir($tree_root . $rcs_path . $relative_path); - $obj->workdir($tree_root . $chkpt_path . $relative_path); - - # check out and lock - if ($lock) { - $obj->co("-l"); - } - - # check out read only - else { - $obj->co; - } -} diff --git a/cpan/dist/Rcs/examples/co.pl b/cpan/dist/Rcs/examples/co.pl deleted file mode 100755 index de0208db..00000000 --- a/cpan/dist/Rcs/examples/co.pl +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# Check-out source file. -#------------------------------------------ -use strict; -use Rcs; - -Rcs->bindir('/usr/bin'); -Rcs->quiet(0); # turn off quiet mode -my $obj = Rcs->new; - -print "Quiet mode set\n" if Rcs->quiet; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("testfile"); -my $revision = shift || $obj->head; -die "Revision $revision does not exist\n" - unless grep /^$revision$/, $obj->revisions; - -$obj->co("-l${revision}"); diff --git a/cpan/dist/Rcs/examples/comments.pl b/cpan/dist/Rcs/examples/comments.pl deleted file mode 100755 index 55b0c055..00000000 --- a/cpan/dist/Rcs/examples/comments.pl +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# Access comments hash -#------------------------------------------ -use strict; -use lib '.'; -use Rcs; - -Rcs->bindir('/usr/bin'); -my $obj = Rcs->new; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("testfile"); - -my %comments = $obj->comments; -my $revision; -foreach $revision (keys %comments) { - #my $comments = $comments{$revision} ? $comments{$revision} : 'GGG'; - my $comments = $comments{$revision}; - print "======\n"; - print "Revision: $revision\n"; - print "$comments###\n"; -} diff --git a/cpan/dist/Rcs/examples/comments2.pl b/cpan/dist/Rcs/examples/comments2.pl deleted file mode 100755 index 9a2b7dae..00000000 --- a/cpan/dist/Rcs/examples/comments2.pl +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# Access comments hash -#------------------------------------------ -use strict; -use lib '.'; -use Rcs; - -Rcs->bindir('/usr/bin'); -my $obj = Rcs->new; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("Rcs.pm"); - -my %comments = $obj->comments; -my $revision; -foreach $revision (sort keys %comments) { - #my $comments = $comments{$revision} ? $comments{$revision} : 'GGG'; - my $comments = $comments{$revision}; - print "======\n"; - print "Revision: $revision\n"; - print "$comments###\n"; -} diff --git a/cpan/dist/Rcs/examples/daterev.pl b/cpan/dist/Rcs/examples/daterev.pl deleted file mode 100755 index f6b7c6ac..00000000 --- a/cpan/dist/Rcs/examples/daterev.pl +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# Test daterev method -#------------------------------------------ -use strict; -use Time::Local; -use lib '.'; -use Rcs; - -Rcs->bindir('/usr/bin'); -my $obj = Rcs->new; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("testfile"); - -my @date_array = @ARGV; -my($year, $mon, $mday, $hour, $min, $sec) = @date_array; -$mon--; # convert to 0-11 range -my $target_time = timegm($sec, $min, $hour, $mday, $mon, $year); - -print "Called as 6 argument method\n"; -# scalar mode -my $revision = $obj->daterev(@date_array); -my $date_str = gmtime($obj->revdate($revision)); -print "Date : Revision = $date_str : $revision\n\n"; - - -# list mode -print "List mode\n"; -my @revisions = $obj->daterev(@date_array); -foreach (@revisions) { - $date_str = gmtime($obj->revdate($_)); - print "Date : Revision = $date_str : $_\n"; -} - - -print "\n\n\n"; -print "Called as 1 argument method\n"; -print "Time number is $target_time\n"; -$revision = $obj->daterev($target_time); -$date_str = gmtime($obj->revdate($revision)); -print "Date : Revision = $date_str : $revision\n\n"; - - -# list mode -print "List mode\n"; -@revisions = $obj->daterev($target_time); -foreach (@revisions) { - $date_str = gmtime($obj->revdate($_)); - print "Date : Revision = $date_str : $_\n"; -} - diff --git a/cpan/dist/Rcs/examples/dates.pl b/cpan/dist/Rcs/examples/dates.pl deleted file mode 100755 index 2d82a800..00000000 --- a/cpan/dist/Rcs/examples/dates.pl +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# Access dates hash -#------------------------------------------ -use strict; -use Rcs; - -#Rcs->bindir('/usr/bin'); -my $obj = Rcs->new; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("testfile"); - -# sort by date -my %dates_hash = $obj->dates; -my $revision; -my %dates; -foreach $revision (keys %dates_hash) { - my $date = $dates_hash{$revision}; - $dates{$date}{$revision} = 1; -} - -my $date; -foreach $date (reverse sort keys %dates) { - foreach $revision (keys %{ $dates{$date} }) { - my $date_str = localtime($date); - print "Revision : Date = $revision : $date_str\n"; - } -} - -# scalar mode returns most recent date -print "\n"; -my $most_recent = localtime($obj->dates); -print "Most recent revision date = $most_recent\n"; diff --git a/cpan/dist/Rcs/examples/green.txt b/cpan/dist/Rcs/examples/green.txt deleted file mode 100644 index 8c5b40d2..00000000 --- a/cpan/dist/Rcs/examples/green.txt +++ /dev/null @@ -1,85 +0,0 @@ -From - Fri Sep 4 19:24:30 1998 -Return-Path: <greendjf@cvhp152.gpt.co.uk> -Received: from cvis01.gpt.co.uk (cvis01.gpt.co.uk [195.99.244.34]) - by onella.admc.com (8.9.0/8.9.0) with SMTP id DAA00464 - for <craig@admc.com>; Thu, 3 Sep 1998 03:45:15 -0400 -Received: from cvfw01 by cvis01.gpt.co.uk with SMTP - (SMI-8.6/GPT-01b5) id IAA03221; Thu, 3 Sep 1998 08:34:39 +0100 -Received: from cvhp152 (cvhp152.gpt.co.uk) by cvhp99.gpt.co.uk with SMTP - (1.37.109.17/99-21) id AA007258250; Thu, 3 Sep 1998 08:37:30 +0100 -Received: from cvhp267.gpt.co.uk by cvhp152 with SMTP - (1.38.193.4/MAIL-15) id AA12641; Thu, 3 Sep 1998 08:37:30 +0100 -Sender: greendjf@cvhp152.gpt.co.uk -Message-Id: <35EE4739.A3A04AD1@cvhp152.gpt.co.uk> -Date: Thu, 03 Sep 1998 08:37:29 +0100 -From: David Green <greendjf@cvhp152.gpt.co.uk> -Organization: GPT Ltd, U.K. -X-Mailer: Mozilla 4.06 [en] (X11; I; HP-UX B.10.20 9000/715) -Mime-Version: 1.0 -To: Craig <craig@admc.com> -Subject: Re: Rcs.pm 0.07 -References: <359A81C3.3AD5@freter.com> <359B3C03.EF608041@cvhp152.gpt.co.uk> <359B6955.CCA0F605@freter.com> <35E67CD9.19DEDCE1@cvhp152.gpt.co.uk> <35EAA99F.471156A@freter.com> <35EC0CD8.C955E86B@cvhp152.gpt.co.uk> <35EDCEF8.1FB4517D@admc.com> -Content-Type: text/plain; charset=us-ascii -Content-Transfer-Encoding: 7bit - -Craig wrote: -Craig, - -I've tried out your new code for daterev and it works ok except that my -version of perl, 5.004_04, complained that $target_time was not defined -(out of scope) a few lines up from the bottom of the method. I had to -define $target_time before the if (@_ == 6) test. - -sub daterev { - my $self = shift; - - # ensure date has all the elements - if (@_ != 1 and @_ != 6) { - croak "daterev must either 1 or 6 arguments"; - } - - my $target_time; - if (@_ == 6) { # string date passed - my($year, $mon, $mday, $hour, $min, $sec) = @_; - - if($year !~ /^\d{4}$/) { - croak "year (1st param) must be 4 digit number"; - } - - $mon--; # convert to 0-11 range - $target_time = timegm($sec, $min, $hour, $mday, $mon, $year); - } - else { # system date passed - $target_time = shift; - } - - if (not defined $self->{DATE}) { - _parse_rcs_header($self); - } - - - my @revisions; - my %dates; - - my %dates_hash = %{$self->{DATE}}; - foreach $revision (keys %dates_hash) { - my $date = $dates_hash{$revision}; - $dates{$date}{$revision} = 1; - } - - my $date; - foreach $date (reverse sort keys %dates) { - foreach $revision (keys %{ $dates{$date} }) { - push @revisions, $revision if $date <= $target_time; - } - } - - return wantarray ? @revisions : $revisions[0]; -} - - -Regards, - -David. -____________________________________________________________________ -David Green, AD4541, GPT Coventry, (740) 2821 greendjf@ncp.gpt.co.uk diff --git a/cpan/dist/Rcs/examples/mark.pl b/cpan/dist/Rcs/examples/mark.pl deleted file mode 100755 index 01f4f98e..00000000 --- a/cpan/dist/Rcs/examples/mark.pl +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# Unlock RCS file -#------------------------------------------ -use strict; -use Rcs; - -Rcs->bindir('/usr/bin'); -Rcs->quiet(0); -my $obj = Rcs->new; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("testfile"); -(my $symbol = shift) or die "Usage: $0 symbol [revision]\n"; -my $revision = shift || $obj->head; -die "Revision $revision does not exist\n" - unless grep /^$revision$/, $obj->revisions; - -$obj->rcs("-n${symbol}:${revision}"); - diff --git a/cpan/dist/Rcs/examples/parse.pl b/cpan/dist/Rcs/examples/parse.pl deleted file mode 100755 index 50fb67c1..00000000 --- a/cpan/dist/Rcs/examples/parse.pl +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# Parse RCS archive file. -#------------------------------------------ -use strict; -use Rcs; - -Rcs->bindir('/usr/bin'); -my $obj = Rcs->new; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("testfile"); - -my $head_rev = $obj->head; -my $locker = $obj->lock; -my $author = $obj->author; -my @access = $obj->access; -my @revisions = $obj->revisions; - -my $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 (@revisions) { - print "Revision: $_\n"; -} diff --git a/cpan/dist/Rcs/examples/pause b/cpan/dist/Rcs/examples/pause deleted file mode 100644 index 4141ffd6..00000000 --- a/cpan/dist/Rcs/examples/pause +++ /dev/null @@ -1 +0,0 @@ -http://www.perl.com/CPAN-local/modules/04pause.html diff --git a/cpan/dist/Rcs/examples/project/src/Rcs.pm b/cpan/dist/Rcs/examples/project/src/Rcs.pm deleted file mode 100644 index 03241de1..00000000 --- a/cpan/dist/Rcs/examples/project/src/Rcs.pm +++ /dev/null @@ -1,1320 +0,0 @@ -package Rcs; -require 5.001; -use strict; -use Carp; -use Time::Local; -use vars qw($VERSION $revision); - -#------------------------------------------------------------------ -# global stuff -#------------------------------------------------------------------ -$VERSION = '0.08'; -$revision = '$Id: Rcs.pm,v 1.14 1998/07/23 01:00:23 freter Exp freter $'; -my $Dir_Sep = ($^O eq 'MSWin32') ? '\\' : '/'; -my $Exe_Ext = ($^O eq 'MSWin32') ? '.exe' : ''; -my $Rcs_Bin_Dir = '/usr/local/bin'; -my $Rcs_Dir = '.' . $Dir_Sep . 'RCS'; -my $Work_Dir = '.'; -my $Quiet = 1; # RCS quiet mode -my $Arc_Ext = ',v'; - -#------------------------------------------------------------------ -# RCS object constructor -#------------------------------------------------------------------ -sub new { - my $proto = shift; - my $class = ref($proto) || $proto; - my $self = {}; - - # provide default values for system stuff - $self->{"_BINDIR"} = \$Rcs_Bin_Dir; - $self->{"_QUIET"} = \$Quiet; - $self->{"_RCSDIR"} = \$Rcs_Dir; - $self->{"_WORKDIR"} = \$Work_Dir; - $self->{"_ARCEXT"} = \$Arc_Ext; - - $self->{FILE} = undef; - $self->{ARCFILE} = undef; - $self->{AUTHOR} = undef; - $self->{COMMENTS} = undef; - $self->{DATE} = undef; - $self->{LOCK} = undef; - $self->{ACCESS} = []; - $self->{REVISIONS} = []; - $self->{REVINFO} = undef; - $self->{STATE} = undef; - $self->{SYMBOLS} = undef; - bless($self, $class); - return $self; -} - -#------------------------------------------------------------------ -# access -# Access list of archive file. -#------------------------------------------------------------------ -sub access { - my $self = shift; - - if (not @{ $self->{ACCESS} }) { - _parse_rcs_header($self); - } - - # dereference revisions list - my @access = @{ $self->{ACCESS} }; - - return @access; -} - -#------------------------------------------------------------------ -# arcext -# Set the RCS archive file extension (default is ',v'). -#------------------------------------------------------------------ -sub arcext { - my $self = shift; - - # called as object method - if (ref $self) { - if (@_) { ${ $self->{"_ARCEXT"} } = shift }; - return ${ $self->{"_ARCEXT"} }; - } - - # called as class method - else { - if (@_) { $Arc_Ext = shift; } - return $Arc_Ext; - } -} - -#------------------------------------------------------------------ -# arcfile -# Name of RCS archive file. -# If not set then return name of working file with RCS -# extension (',v'). -#------------------------------------------------------------------ -sub arcfile { - my $self = shift; - if (@_) { $self->{ARCFILE} = shift } - return $self->{ARCFILE} || $self->{FILE} . ${ $self->{"_ARCEXT"} }; -} - -#------------------------------------------------------------------ -# author -# Return the author of an RCS revision. -# If revision is not provided, default to 'head' revision. -#------------------------------------------------------------------ -sub author { - my $self = shift; - - if (not defined $self->{AUTHOR}) { - _parse_rcs_header($self); - } - my $revision = shift || $self->{HEAD}; - - # dereference author hash - my %author_array = %{ $self->{AUTHOR} }; - - return $author_array{$revision}; -} - -#------------------------------------------------------------------ -# bindir -# Set the bin directory in which the RCS distribution programs -# reside. -#------------------------------------------------------------------ -sub bindir { - my $self = shift; - - # called as object method - if (ref $self) { - if (@_) { ${ $self->{"_BINDIR"} } = shift }; - return ${ $self->{"_BINDIR"} }; - } - - # called as class method - else { - if (@_) { $Rcs_Bin_Dir = shift }; - return $Rcs_Bin_Dir; - } -} - -#------------------------------------------------------------------ -# ci -# Execute RCS 'ci' program. -# Make archive filename same as working filename unless -# specifically set. -#------------------------------------------------------------------ -sub ci { - my $self = shift; - my @param = @_; - - my $ciprog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'ci' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $workdir = ${ $self->{"_WORKDIR"} }; - my $file = $self->{FILE}; - my $arcfile = $self->{ARCFILE} || $file; - - my $archive_file = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - my $workfile = $workdir . $Dir_Sep . $file; - push @param, $archive_file, $workfile; - unshift @param, "-q" if ${ $self->{"_QUIET"} }; # quiet mode - - # run program - croak "ci program $ciprog not found" unless -e $ciprog; - croak "ci program $ciprog not executable" unless -x $ciprog; - system($ciprog, @param) == 0 or croak "$!"; - - # re-parse RCS file and clear comments hash - _parse_rcs_header($self); - $self->{COMMENTS} = undef; -} - -#------------------------------------------------------------------ -# co -# Execute RCS 'co' program. -# Make archive filename same as working filename unless -# specifically set. -#------------------------------------------------------------------ -sub co { - my $self = shift; - my @param = @_; - - my $coprog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'co' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $workdir = ${ $self->{"_WORKDIR"} }; - my $file = $self->{FILE}; - my $arcfile = $self->{ARCFILE} || $file; - - my $archive_file = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - my $workfile = $workdir . $Dir_Sep . $file; - push @param, $archive_file, $workfile; - unshift @param, "-q" if ${ $self->{"_QUIET"} }; # quiet mode - - # run program - croak "co program $coprog not found" unless -e $coprog; - croak "co program $coprog not executable" unless -x $coprog; - system($coprog, @param) == 0 or croak "$!"; - - # re-parse RCS file and clear comments hash - _parse_rcs_header($self); - $self->{COMMENTS} = undef; -} - -#------------------------------------------------------------------ -# comments -#------------------------------------------------------------------ -sub comments { - my $self = shift; - - if (not defined $self->{COMMENTS}) { - _parse_rcs_body($self); - } - - return %{$self->{COMMENTS}}; -} - -#------------------------------------------------------------------ -# daterev -# Returns a revision which was current at a specified date/time. -# 0 is returned if all revisions are newer than the date -# specified. This usually means the file did not exist on that -# date. -# This takes 6 parameters, year (4 digit year), month (1-12), day -# of month (1-31), hour (0-23), minute (0-59) and second (0-59). -#------------------------------------------------------------------ -sub daterev { - my $self = shift; - my($year, $mon, $mday, $hour, $min, $sec) = @_; - - # ensure date has all the elements - if(@_ != 6) { - croak "daterev must have 6 element date/time (year, month, day, hour, min, sec)"; - } - - if($year !~ /^\d{4}$/) { - croak "year (1st param) must be 4 digit number"; - } - - if (not defined $self->{DATE}) { - _parse_rcs_header($self); - } - - $mon--; # convert to 0-11 range - my $target_time = timegm($sec, $min, $hour, $mday, $mon, $year); - my @revisions; - my %dates; - - my %dates_hash = %{$self->{DATE}}; - foreach $revision (keys %dates_hash) { - my $date = $dates_hash{$revision}; - $dates{$date}{$revision} = 1; - } - - my $date; - foreach $date (reverse sort keys %dates) { - foreach $revision (keys %{ $dates{$date} }) { - push @revisions, $revision if $date <= $target_time; - } - } - - return wantarray ? @revisions : $revisions[0]; -} - -#------------------------------------------------------------------ -# dates -# Return a hash of revision dates, keyed on revision, when called -# in list mode. -# Return the most recent date when called in scalar mode. -# -# RCS stores dates in GMT. -# The date values are system dates. -#------------------------------------------------------------------ -sub dates { - my $self = shift; - - if (not defined $self->{DATE}) { - _parse_rcs_header($self); - } - - my %DatesHash = %{$self->{DATE}}; - my @dates_list = sort {$b<=>$a} values %DatesHash; - my $MostRecent = $dates_list[0]; - - return wantarray ? %DatesHash : $MostRecent; -} - -#------------------------------------------------------------------ -# file -# Name of working file. -#------------------------------------------------------------------ -sub file { - my $self = shift; - if (@_) { $self->{FILE} = shift } - return $self->{FILE}; -} - -#------------------------------------------------------------------ -# head -# Return the head revision. -#------------------------------------------------------------------ -sub head { - my $self = shift; - - if (not defined $self->{HEAD}) { - _parse_rcs_header($self); - } - return $self->{HEAD}; -} - -#------------------------------------------------------------------ -# lock -# Return user who has file locked. -#------------------------------------------------------------------ -sub lock { - my $self = shift; - - if (not defined $self->{LOCK}) { - _parse_rcs_header($self); - } - return $self->{LOCK}; -} - -#------------------------------------------------------------------ -# quiet -# Set or un-set RCS quiet mode. -#------------------------------------------------------------------ -sub quiet { - my $self = shift; - - # called as object method - if (ref $self) { - - # set/un-set quiet mode - if (@_) { - my $mode = shift; - croak "Passed parameter must be either '0' or '1'" - unless $mode == 0 or $mode == 1; - ${ $self->{"_QUIET"} } = $mode; - return ${ $self->{"_QUIET"} }; - } - - # access quiet mode - else { - return ${ $self->{"_QUIET"} }; - } - } - - # called as class method - else { - - # set/un-set quiet mode - if (@_) { - my $mode = shift; - croak "Passed parameter must be either '0' or '1'" - unless $mode == 0 or $mode == 1; - $Quiet = $mode; - return $Quiet; - } - - # access quiet mode - else { - return $Quiet; - } - } -} - -#------------------------------------------------------------------ -# rcs -# Execute RCS 'rcs' program. -# Make archive filename same as working filename unless -# specifically set. -#------------------------------------------------------------------ -sub rcs { - my $self = shift; - my @param = @_; - - my $rcsprog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'rcs' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $workdir = ${ $self->{"_WORKDIR"} }; - my $file = $self->{FILE}; - my $arcfile = $self->{ARCFILE} || $file; - - my $archive_file = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - my $workfile = $workdir . $Dir_Sep . $file; - push @param, $archive_file, $workfile; - unshift @param, "-q" if ${ $self->{"_QUIET"} }; # quiet mode - - # run program - croak "rcs program $rcsprog not found" unless -e $rcsprog; - croak "rcs program $rcsprog not executable" unless -x $rcsprog; - system($rcsprog, @param) == 0 or croak "$?"; - - # re-parse RCS file and clear comments hash - _parse_rcs_header($self); - $self->{COMMENTS} = undef; -} - -#------------------------------------------------------------------ -# rcsclean -# Execute RCS 'rcsclean' program. -#------------------------------------------------------------------ -sub rcsclean { - my $self = shift; - my @param = @_; - - my $rcscleanprog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'rcsclean' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $workdir = ${ $self->{"_WORKDIR"} }; - my $file = $self->{FILE}; - my $arcfile = $self->{ARCFILE} || $file; - - my $archive_file = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - my $workfile = $workdir . $Dir_Sep . $file; - push @param, $archive_file, $workfile; - - # run program - croak "rcsclean program $rcscleanprog not found" unless -e $rcscleanprog; - croak "rcsclean program $rcscleanprog not executable" unless -x $rcscleanprog; - system($rcscleanprog, @param) == 0 or croak "$?"; - - # re-parse RCS file and clear comments hash - _parse_rcs_header($self); - $self->{COMMENTS} = undef; -} - -#------------------------------------------------------------------ -# rcsdiff -# Execute RCS 'rcsdiff' program. -# Calling in list context returns the output of rcsdiff, while -# calling in scalar context returns the return status of the -# rcsdiff program. -#------------------------------------------------------------------ -sub rcsdiff { - my $self = shift; - my @param = @_; - - my $rcsdiff_prog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'rcsdiff' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $arcfile = $self->{ARCFILE} || $self->{FILE}; - $arcfile = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - my $workfile = $self->workdir . $Dir_Sep . $self->file; - - # un-taint parameter string - unshift @param, "-q" if ${ $self->{"_QUIET"} }; # quiet mode - my $param_str = join(' ', @param); - $param_str =~ s/([\w-]+)/$1/g; - - croak "rcsdiff program $rcsdiff_prog not found" unless -e $rcsdiff_prog; - croak "rcsdiff program $rcsdiff_prog not executable" unless -x $rcsdiff_prog; - open(DIFF, "$rcsdiff_prog $param_str $arcfile $workfile |"); - my @diff_output = <DIFF>; - - # rcsdiff returns exit status 0 for no differences, 1 for differences, - # and 2 for error condition. - close DIFF; - my $status = $?; - croak "$rcsdiff_prog failed" if $status == 2; - return wantarray ? @diff_output : $status; -} - -#------------------------------------------------------------------ -# rcsdir -# Location of 'RCS' archive directory. -#------------------------------------------------------------------ -sub rcsdir { - my $self = shift; - - # called as object method - if (ref $self) { - if (@_) { ${ $self->{"_RCSDIR"} } = shift } - return ${ $self->{"_RCSDIR"} }; - } - - # called as class method - else { - if (@_) { $Rcs_Dir = shift } - return $Rcs_Dir; - } -} - -#------------------------------------------------------------------ -# revdate -# Return the revision date of an RCS revision. -# If revision is not provided, default to 'head' revision. -# -# RCS stores dates in GMT. This method will return dates relative -# to the local time zone. -#------------------------------------------------------------------ -sub revdate { - my $self = shift; - - if (not defined $self->{DATE}) { - _parse_rcs_header($self); - } - my $revision = shift || $self->{HEAD}; - - # dereference date hash - my %date_array = %{ $self->{DATE} }; - my $date_str = $date_array{$revision}; - - return wantarray ? localtime($date_str) : $date_str; -} - -#------------------------------------------------------------------ -# revisions -#------------------------------------------------------------------ -sub revisions { - my $self = shift; - - if (not @{ $self->{REVISIONS} }) { - _parse_rcs_header($self); - } - - # dereference revisions list - my @revisions = @{ $self->{REVISIONS} }; - - @revisions; -} - -#------------------------------------------------------------------ -# rlog -# Execute RCS 'rlog' program. -# Make archive filename same as working filename unless -# specifically set. -#------------------------------------------------------------------ -sub rlog { - my $self = shift; - my @param = @_; - - my $rlogprog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'rlog' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $arcfile = $self->{ARCFILE} || $self->{FILE}; - - # un-taint parameter string - my $param_str = join(' ', @param); - $param_str =~ s/([\w-]+)/$1/g; - - my $archive_file = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - croak "rlog program $rlogprog not found" unless -e $rlogprog; - croak "rlog program $rlogprog not executable" unless -x $rlogprog; - open(RLOG, "$rlogprog $param_str $archive_file |"); - - my @logoutput = <RLOG>; - close RLOG; - croak "$rlogprog failed" if $?; - @logoutput; -} - -#------------------------------------------------------------------ -# state -# If revision is not provided, default to 'head' revision -#------------------------------------------------------------------ -sub state { - my $self = shift; - - if (not defined $self->{STATE}) { - _parse_rcs_header($self); - } - my $revision = shift || $self->{HEAD}; - - # dereference author hash - my %state_array = %{ $self->{STATE} }; - - return $state_array{$revision}; -} - -#------------------------------------------------------------------ -# symbol -# If revision is not provided, default to 'head' revision -#------------------------------------------------------------------ -sub symbol { - my $self = shift; - - if (not defined $self->{SYMBOLS}) { - _parse_rcs_header($self); - } - my $revision = shift || $self->{HEAD}; - - # dereference symbols hash - my %sym_array = %{ $self->{SYMBOLS} }; - - return '' if not defined $sym_array{$revision}; - - my @symbols = @{ $sym_array{$revision} }; - - # return only first array element if user wants scalar - return wantarray ? @symbols : $symbols[0]; -} - -#------------------------------------------------------------------ -# symbols -# Returns hash of all revisions keyed on symbol defined against file. -#------------------------------------------------------------------ -sub symbols { - my $self = shift; - - if(not defined $self->{SYMBOLS}) { - _parse_rcs_header($self); - } - - my %symbols; - - # loop through each revision - my $rev; - foreach $rev (@{ $self->{REVISIONS} }) { - my $sym; - foreach $sym (@{ $self->{SYMBOLS}->{$rev} }) { - $symbols{$sym} = $rev; - } - } - return %symbols; -} - -#------------------------------------------------------------------ -# symrev -# 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. -#------------------------------------------------------------------ -sub symrev { - my $self = shift; - my $sym = shift; - if(! defined $sym) { - croak "You must supply a symbol to symrev"; - } - - if (not defined $self->{SYMBOLS}) { - _parse_rcs_header($self); - } - - my $ret_rev = 0; - my %symbols; - - # loop through each revision - my $rev; - REV_LOOP: - foreach $rev (@{ $self->{REVISIONS} }) { - # loop through each symbol defined against - # this revision - my $s; - foreach $s (@{ $self->{SYMBOLS}->{$rev} }) { - - # store each revision matching the pattern - if (wantarray) { - $symbols{$s} = $rev if $s =~ /$sym/; - } - - # if it's the one we're looking for, we can - # quit as we've found the revision we want - else { - if($s eq $sym) { - $ret_rev = $rev; - last REV_LOOP; - } - } - } - } - - return wantarray ? %symbols : $ret_rev; -} - -#------------------------------------------------------------------ -# workdir -# Location of working directory. -#------------------------------------------------------------------ -sub workdir { - my $self = shift; - - # called as object method - if (ref $self) { - if (@_) { ${ $self->{"_WORKDIR"} } = shift } - return ${ $self->{"_WORKDIR"} }; - } - - # called as class method - else { - if (@_) { $Work_Dir = shift } - return $Work_Dir; - } -} - -#------------------------------------------------------------------ -# _parse_rcs_body -# Private function -#------------------------------------------------------------------ -sub _parse_rcs_body { - - my $self = shift; - local $_; - - my %comments; - - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $file = $self->{FILE}; - my $rcs_file = $rcsdir . $Dir_Sep . $file . ${ $self->{"_ARCEXT"} }; - - # parse RCS archive file - open RCS_FILE, $rcs_file or croak "Unable to open $rcs_file"; - - # skip header info and get description - DESC: while (<RCS_FILE>) { - if (/^desc$/) { - $comments{0} = ''; - $_ = <RCS_FILE>; - s/^\@//; # remove leading '@' - while (1) { - last DESC if /^\@$/; - s/\@\@/\@/g; # RCS replaces single '@' with '@@' - $comments{0} .= $_; - $_ = <RCS_FILE>; - } - } - } - - # parse revision comments - my $revision; - REVISION: while (<RCS_FILE>) { - if (/^[\d\.]+$/) { - chomp($revision = $_); - $_ = <RCS_FILE>; - if (/^log$/) { - $comments{$revision} = ''; - $_ = <RCS_FILE>; - s/^\@//; # remove leading '@' - while (1) { - next REVISION if /^\@$/; - s/\@\@/\@/g; # RCS replaces single '@' with '@@' - $comments{$revision} .= $_; - $_ = <RCS_FILE>; - } - } - } - } - - # loop through 'text' section to avoid capturing false comments - continue { - if (/^text$/) { - while (<RCS_FILE>) {last if /^\@$/} - } - } - - close RCS_FILE; - - $self->{COMMENTS} = \%comments; -} - -#------------------------------------------------------------------ -# _parse_rcs_header -# Private function -# Directly parse the RCS archive file. -#------------------------------------------------------------------ -sub _parse_rcs_header { - - my $self = shift; - local $_; - - my ($head, $lock); - my (@access_list, @revisions); - my (%author, %date, %state, %symbols); - - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $file = $self->{FILE}; - my $rcs_file = $rcsdir . $Dir_Sep . $file . ${ $self->{"_ARCEXT"} }; - - # parse RCS archive file - open RCS_FILE, $rcs_file - or croak "Unable to open $rcs_file"; - while (<RCS_FILE>) { - next if /^\s*$/; # skip blank lines - last if /^desc$/; # end of header info - - # get head revision - if (/^head\s/) { - ($head) = /^head\s+(.*?);$/; - next; - } - - # get access list - if (/^access$/) { - while (<RCS_FILE>) { - chomp; - s/\s//g; # remove all whitespace - push @access_list, (split(/;/))[0]; - last if /;$/; - } - next; - } - - # get locker - # get symbols - if (/^symbols$/) { - while (<RCS_FILE>) { - chomp; - s/\s//g; # remove all whitespace - my ($sym, $rev) = split(/:/); - $rev =~ s/;$//; - push @{ $symbols{$rev} }, $sym; - last if /;$/; - } - next; - } - - # get locker - if (/^locks/) { - - # file not locked - if (/strict/) { - $lock = ''; - next; - } - - # get user who has file locked - my $next_line = <RCS_FILE>; # read next line - ($lock) = $next_line =~ m/^\s*(\w+):/; - next; - } - - # get all revisions - if (/^\d+\.\d+/) { - chomp; - push @revisions, $_; - - # get author, state and date of each revision - my $next_line = <RCS_FILE>; - chop(my $author = (split(/\s+/, $next_line))[3]); - chop(my $state = (split(/\s+/, $next_line))[5]); - chop(my $date = (split(/\s+/, $next_line))[1]); - - # store date as date number - my ($year, $mon, $mday, $hour, $min, $sec) = split(/\./, $date); - $mon--; # convert to 0-11 range - my @date = ($sec,$min,$hour,$mday,$mon,$year); - - # store value in hash using revision as key - $author{$_} = $author; - $state{$_} = $state; - $date{$_} = timegm(@date); - } - } - close RCS_FILE; - - $self->{HEAD} = $head; - $self->{LOCK} = $lock; - $self->{ACCESS} = \@access_list; - $self->{REVISIONS} = \@revisions; - $self->{AUTHOR} = \%author; - $self->{DATE} = \%date; - $self->{STATE} = \%state; - $self->{SYMBOLS} = \%symbols; -} - -1; - -__END__ - -=head1 NAME - -Rcs - Perl Object Class for Revision Control System (RCS). - -=head1 SYNOPSIS - - use Rcs; - -=head1 DESCRIPTION - -This Perl module provides an object oriented interface to access -B<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. - -=head2 OBJECT CONSTRUCTOR - -The B<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; - -=head2 CLASS METHODS - -Besides the object constructor, there are three class methods provided -which effect any newly created objects. - -The B<arcext> method sets the RCS archive extension, which is ',v' by -default. - - # set/unset RCS archive extension - Rcs->arcext(''); # set no archive extension - Rcs->arcext(',v'); # set archive extension to ',v' - $arc_ext = Rcs->arcext(); # get current archive extension - -The B<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 B<quiet> method sets/unsets the quiet mode for the RCS executables. -Quiet mode is set by 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->arcext(''); - $obj->bindir('/usr/bin'); - $obj->quiet(0); - -=head2 OBJECT ATTRIBUTE METHODS - -These methods set the attributes of the RCS object. - -The B<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 B<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 -RCS archive extension (default ',v') is automatically added to the filename. - - $obj->arcfile('principle_mcvicker.pl'); - -The B<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 B<rcsdir> methods set the path of the RCS archive directory. If not -specified, default path is './RCS'. - - $obj->rcsdir('/usr/local/archive'); - -=head2 RCS PARSE METHODS - -This class provides methods to directly parse the RCS archive file. - -The B<access> method returns a list of all user on the access list. - - @access_list = $obj->access; - -The B<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 B<head> method returns the head revision. - - $head = $obj->head; - -The B<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 B<revisions> method returns a list of all revisions of archive file. - - @revisions = $obj->revisions; - -The B<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 B<symbol> method returns the symbol(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 a 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 B<symbols> method returns a hash, keyed by symbol, of all of the revisions -associated with the file. - - %symbols = $obj->symbols; - foreach $sym (keys %symbols) { - $rev = $symbols{$sym}; - } - -The B<revdate> 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. - - # scalar mode - $scalar_date = $obj->revdate; - print "Scalar date number = $scalar_date\n"; - $date_str = localtime($scalar_date); - print "Scalar date string = $date_str\n"; - - # list mode - @list_date = $obj->revdate; - print "List date = @list_date\n"; - -The B<dates> 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. - - # list mode - %DatesHash = obj->dates; - @dates_list = sort {$b<=>$a} values %DatesHash; - $MostRecent = $dates_list[0]; - - # scalar mode - $most_recent = $obj->dates; - print "Most recent date = $most_recent\n"; - $most_recent_str = localtime($most_recent); - print "Most recent date string = $most_recent_str\n"; - -The B<symrev> 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. - - # gets revision that has 'MY_SYMBOL' defined against it - $rev = symrev('MY_SYMBOL'); - -The B<daterev> method returns a revision which was current at a specified -date/time. If all revisions are newer than the specified date/time, i.e. the -file did not exist then, 0 is returned. - - # gets revision that was active on 25th June 1998 16:45:30 - $rev = daterev(1998, 6, 25, 16, 45, 30); - -The B<comments> method returns a hash of revision comments, keyed on revision. -A key value of 0 returns the description. - - %comments = $obj->comments; - $description = $comments{0}; - $comment_1_3 = $comments{'1.3'}; - -=head2 RCS SYSTEM METHODS - -These methods invoke the RCS system utilities. - -The B<ci> method calls the RCS ci program. - - # check in, and then check out in unlocked state - $obj->ci('-u'); - -The B<co> method calls the RCS co program. - - # check out in locked state - $obj->co('-l'); - -The B<rcs> method calls the RCS rcs program. - - # lock file - $obj->rcs('-l'); - -The B<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 B<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 B<rcsclean> method calls the RCS rcsclean program. - - # remove working file - $obj->rcsclean; - - -=head1 EXAMPLES - -=head2 CREATE ACCESS LIST - -Using method B<rcs> with the B<-a> switch allows you to add users to -the access list of an RCS archive file. - - use Rcs; - $obj = Rcs->new; - - $obj->rcsdir("./project_tree/archive"); - $obj->workdir("./project_tree/src"); - $obj->file("cornholio.pl"); - -Methos B<rcs> invokes the RCS utility rcs with the same parameters. - - @users = qw(beavis butthead); - $obj->rcs("-a@users"); - -Calling method B<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"; - - -=head2 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 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"; - } - -=head2 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 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 B<-u> switch. This will check in the file, and will then -check out the file in an unlocked state. The B<-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; - -=head2 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 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'); - -=head2 RCSDIFF - -Method B<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'); - -=head2 RCSCLEAN - -Method B<rcsclean> will remove an unlocked working file. - - use 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; - -=head1 AUTHOR - -Craig Freter, E<lt>F<craig@freter.com>E<gt> - -=head1 CONTRIBUTORS - -David Green, E<lt>F<greendjf@cvhp152.gpt.co.uk>E<gt> - - David Green contributed the B<dates> method. - -Jamie O'Shaughnessy, E<lt>F<jamie@thanatar.demon.co.uk>E<gt> - - Contributed NT port. - Contributed methods B<daterev>, B<symrev>, and B<symbols>. - -=head1 COPYRIGHT - -Copyright (C) 1997,1998 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. - -=cut - diff --git a/cpan/dist/Rcs/examples/project/src/testfile b/cpan/dist/Rcs/examples/project/src/testfile deleted file mode 100644 index 59d119de..00000000 --- a/cpan/dist/Rcs/examples/project/src/testfile +++ /dev/null @@ -1,2 +0,0 @@ -3.14 -hear again diff --git a/cpan/dist/Rcs/examples/rcsclean.pl b/cpan/dist/Rcs/examples/rcsclean.pl deleted file mode 100755 index 957cfc73..00000000 --- a/cpan/dist/Rcs/examples/rcsclean.pl +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# rcsclean utility -#------------------------------------------ -use strict; -use Rcs; - -Rcs->quiet(0); # turn off quiet mode -Rcs->bindir('/usr/bin'); -my $obj = Rcs->new; - -print "Quiet mode NOT set\n" unless Rcs->quiet; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("testfile"); - -$obj->rcsclean; diff --git a/cpan/dist/Rcs/examples/rcsdiff.pl b/cpan/dist/Rcs/examples/rcsdiff.pl deleted file mode 100755 index 7bd343f9..00000000 --- a/cpan/dist/Rcs/examples/rcsdiff.pl +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# Use rcsdiff utility. -#------------------------------------------ -use strict; -use Rcs; - -Rcs->quiet(1); - -my $obj = Rcs->new; -$obj->bindir('/usr/bin'); -print "Quiet mode set\n" if Rcs->quiet; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("testfile"); - -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'); diff --git a/cpan/dist/Rcs/examples/revdate.pl b/cpan/dist/Rcs/examples/revdate.pl deleted file mode 100755 index b20669f8..00000000 --- a/cpan/dist/Rcs/examples/revdate.pl +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# Get revision date -#------------------------------------------ -use strict; -use Rcs; - -Rcs->bindir('/usr/bin'); -my $obj = Rcs->new; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("testfile"); -my $revision = shift || $obj->head; -die "Revision $revision does not exist\n" - unless grep /^$revision$/, $obj->revisions; - -# scalar mode -my $date_num = $obj->revdate($revision); -print "Revision : Date number = $revision : $date_num\n"; - -my $date_str = localtime($date_num); -print "Revision : Date string = $revision : $date_str\n"; - -# list mode -my @list_date = $obj->revdate($revision); -print "Revision : Date array = $revision : @list_date\n"; - diff --git a/cpan/dist/Rcs/examples/rlog.pl b/cpan/dist/Rcs/examples/rlog.pl deleted file mode 100755 index 14b66886..00000000 --- a/cpan/dist/Rcs/examples/rlog.pl +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# Use rlog utility. -#------------------------------------------ -use strict; -use Rcs; - -my $obj = Rcs->new; - -# call quiet and bindir as objest methods -$obj->quiet(1); -$obj->bindir('/usr/bin'); - -print "Quiet mode set\n" if Rcs->quiet; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("testfile"); - -print $obj->rlog; diff --git a/cpan/dist/Rcs/examples/symbols.pl b/cpan/dist/Rcs/examples/symbols.pl deleted file mode 100755 index ffcafc32..00000000 --- a/cpan/dist/Rcs/examples/symbols.pl +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# Test symrev method -#------------------------------------------ -use strict; -use Rcs; - -Rcs->bindir('/usr/bin'); -my $obj = Rcs->new; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("testfile"); - -my %symbols = $obj->symbols; -my $sym; -foreach $sym (keys %symbols) { - my $rev = $symbols{$sym}; - print "Symbol : Revision = $sym : $rev\n"; -} - -my @syms = keys %symbols; -print "@syms\n"; diff --git a/cpan/dist/Rcs/examples/symrev.pl b/cpan/dist/Rcs/examples/symrev.pl deleted file mode 100755 index 20af459c..00000000 --- a/cpan/dist/Rcs/examples/symrev.pl +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# Test symrev method -#------------------------------------------ -use strict; -use Rcs; - -#Rcs->bindir('/usr/bin'); -my $obj = Rcs->new; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("testfile"); -(my $symbol = shift) or die "Usage: $0 symbol\n"; - -# scalar mode -print "Scalar mode:\n"; -my $revision = $obj->symrev($symbol); -print "Symbol : Revision = $symbol : $revision\n"; - - -# list mode -print "\nList mode:\n"; -my %symbols = $obj->symrev($symbol); -foreach (keys %symbols) { - print "Symbol : Revision = $_ : $symbols{$_}\n"; -} diff --git a/cpan/dist/Rcs/examples/test1.pl b/cpan/dist/Rcs/examples/test1.pl deleted file mode 100755 index 209f9930..00000000 --- a/cpan/dist/Rcs/examples/test1.pl +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/local/bin/perl -w - -use strict; -use lib '.'; -use Rcs; - -my $p = new Rcs(); -$p->workdir("foo"); - -my $n = new Rcs(); -$n->workdir("bar"); - -print $p->workdir, "\n"; -print $n->workdir, "\n"; diff --git a/cpan/dist/Rcs/examples/test2.pl b/cpan/dist/Rcs/examples/test2.pl deleted file mode 100755 index 4992cc9b..00000000 --- a/cpan/dist/Rcs/examples/test2.pl +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/local/bin/perl -w - -use strict; -use lib '.'; -use Rcs; - -Rcs->workdir("foo"); - -my $p = new Rcs(); -my $n = new Rcs(); - -Rcs->workdir("bar"); - -print $p->workdir, "\n"; -print $n->workdir, "\n"; diff --git a/cpan/dist/Rcs/examples/test3.pl b/cpan/dist/Rcs/examples/test3.pl deleted file mode 100755 index 4d0c36ed..00000000 --- a/cpan/dist/Rcs/examples/test3.pl +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/local/bin/perl -w - -use strict; -use lib '.'; -use Rcs; - -my $p = new Rcs(); -my $n = new Rcs(); - -my $m = new Rcs(); -$m->workdir("foo"); - -Rcs->workdir("bar"); - -print $p->workdir, "\n"; -print $n->workdir, "\n"; -print $m->workdir, "\n"; diff --git a/cpan/dist/Rcs/examples/type b/cpan/dist/Rcs/examples/type deleted file mode 100644 index 29a4ee24..00000000 --- a/cpan/dist/Rcs/examples/type +++ /dev/null @@ -1,13 +0,0 @@ -Check-in -./project/RCS/testfile,v <-- ./project/src/testfile -new revision: 1.4; previous revision: 1.3 -enter log message, terminated with single '.' or end of file: ->> @test multi-line comment@@@@@@ ->> @ ->> @@ ->> @@@ ->> @@@@ ->> multiline comment ->> @ ->> . -done diff --git a/cpan/dist/Rcs/examples/unlock.pl b/cpan/dist/Rcs/examples/unlock.pl deleted file mode 100755 index 8d60137c..00000000 --- a/cpan/dist/Rcs/examples/unlock.pl +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/local/bin/perl -w -#------------------------------------------ -# Unlock RCS file -#------------------------------------------ -use strict; -use Rcs; - -Rcs->bindir('/usr/bin'); -Rcs->quiet(0); -my $obj = Rcs->new; - -$obj->rcsdir("./project/RCS"); -$obj->workdir("./project/src"); -$obj->file("testfile"); -my $revision = shift || $obj->head; -die "Revision $revision does not exist\n" - unless grep /^$revision$/, $obj->revisions; - -$obj->rcs("-u${revision}"); - diff --git a/cpan/dist/Rcs/test.pl b/cpan/dist/Rcs/test.pl deleted file mode 100644 index 41c2ffc9..00000000 --- a/cpan/dist/Rcs/test.pl +++ /dev/null @@ -1,20 +0,0 @@ -# Before `make install' is performed this script should be runnable with -# `make test'. After `make install' it should work as `perl test.pl' - -######################### We start with some black magic to print on failure. - -# Change 1..1 below to 1..last_test_to_print . -# (It may become useful if the test is moved to ./t subdirectory.) - -BEGIN { $| = 1; print "1..1\n"; } -END {print "not ok 1\n" unless $loaded;} -use Rcs; -$loaded = 1; -print "ok 1\n"; - -######################### End of black magic. - -# Insert your test code below (better if it prints "ok 13" -# (correspondingly "not ok 13") depending on the success of chunk 13 -# of the test code): - diff --git a/cpan/lib/Rcs.pm b/cpan/lib/Rcs.pm deleted file mode 100644 index 1c6e2f4b..00000000 --- a/cpan/lib/Rcs.pm +++ /dev/null @@ -1,1343 +0,0 @@ -package Rcs; -require 5.001; -use strict; -use Carp; -use Time::Local; -use vars qw($VERSION $revision); - -#------------------------------------------------------------------ -# global stuff -#------------------------------------------------------------------ -$VERSION = '0.09'; -$revision = '$Id: Rcs.pm,v 1.14.1.3 1998/10/19 18:04:48 freter Exp $'; -my $Dir_Sep = ($^O eq 'MSWin32') ? '\\' : '/'; -my $Exe_Ext = ($^O eq 'MSWin32') ? '.exe' : ''; -my $Rcs_Bin_Dir = '/usr/local/bin'; -my $Rcs_Dir = '.' . $Dir_Sep . 'RCS'; -my $Work_Dir = '.'; -my $Quiet = 1; # RCS quiet mode -my $Arc_Ext = ',v'; - -#------------------------------------------------------------------ -# RCS object constructor -#------------------------------------------------------------------ -sub new { - my $proto = shift; - my $class = ref($proto) || $proto; - my $self = {}; - - # provide default values for system stuff - $self->{"_BINDIR"} = \$Rcs_Bin_Dir; - $self->{"_QUIET"} = \$Quiet; - $self->{"_RCSDIR"} = \$Rcs_Dir; - $self->{"_WORKDIR"} = \$Work_Dir; - $self->{"_ARCEXT"} = \$Arc_Ext; - - $self->{FILE} = undef; - $self->{ARCFILE} = undef; - $self->{AUTHOR} = undef; - $self->{COMMENTS} = undef; - $self->{DATE} = undef; - $self->{LOCK} = undef; - $self->{ACCESS} = []; - $self->{REVISIONS} = []; - $self->{REVINFO} = undef; - $self->{STATE} = undef; - $self->{SYMBOLS} = undef; - bless($self, $class); - return $self; -} - -#------------------------------------------------------------------ -# access -# Access list of archive file. -#------------------------------------------------------------------ -sub access { - my $self = shift; - - if (not @{ $self->{ACCESS} }) { - _parse_rcs_header($self); - } - - # dereference revisions list - my @access = @{ $self->{ACCESS} }; - - return @access; -} - -#------------------------------------------------------------------ -# arcext -# Set the RCS archive file extension (default is ',v'). -#------------------------------------------------------------------ -sub arcext { - my $self = shift; - - # called as object method - if (ref $self) { - if (@_) { ${ $self->{"_ARCEXT"} } = shift }; - return ${ $self->{"_ARCEXT"} }; - } - - # called as class method - else { - if (@_) { $Arc_Ext = shift; } - return $Arc_Ext; - } -} - -#------------------------------------------------------------------ -# arcfile -# Name of RCS archive file. -# If not set then return name of working file with RCS -# extension (',v'). -#------------------------------------------------------------------ -sub arcfile { - my $self = shift; - if (@_) { $self->{ARCFILE} = shift } - return $self->{ARCFILE} || $self->{FILE} . ${ $self->{"_ARCEXT"} }; -} - -#------------------------------------------------------------------ -# author -# Return the author of an RCS revision. -# If revision is not provided, default to 'head' revision. -#------------------------------------------------------------------ -sub author { - my $self = shift; - - if (not defined $self->{AUTHOR}) { - _parse_rcs_header($self); - } - my $revision = shift || $self->{HEAD}; - - # dereference author hash - my %author_array = %{ $self->{AUTHOR} }; - - return $author_array{$revision}; -} - -#------------------------------------------------------------------ -# bindir -# Set the bin directory in which the RCS distribution programs -# reside. -#------------------------------------------------------------------ -sub bindir { - my $self = shift; - - # called as object method - if (ref $self) { - if (@_) { ${ $self->{"_BINDIR"} } = shift }; - return ${ $self->{"_BINDIR"} }; - } - - # called as class method - else { - if (@_) { $Rcs_Bin_Dir = shift }; - return $Rcs_Bin_Dir; - } -} - -#------------------------------------------------------------------ -# ci -# Execute RCS 'ci' program. -# Make archive filename same as working filename unless -# specifically set. -#------------------------------------------------------------------ -sub ci { - my $self = shift; - my @param = @_; - - my $ciprog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'ci' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $workdir = ${ $self->{"_WORKDIR"} }; - my $file = $self->{FILE}; - my $arcfile = $self->{ARCFILE} || $file; - - my $archive_file = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - my $workfile = $workdir . $Dir_Sep . $file; - push @param, $archive_file, $workfile; - unshift @param, "-q" if ${ $self->{"_QUIET"} }; # quiet mode - - # run program - croak "ci program $ciprog not found" unless -e $ciprog; - croak "ci program $ciprog not executable" unless -x $ciprog; - system($ciprog, @param) == 0 or croak "$!"; - - # re-parse RCS file and clear comments hash - _parse_rcs_header($self); - $self->{COMMENTS} = undef; -} - -#------------------------------------------------------------------ -# co -# Execute RCS 'co' program. -# Make archive filename same as working filename unless -# specifically set. -#------------------------------------------------------------------ -sub co { - my $self = shift; - my @param = @_; - - my $coprog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'co' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $workdir = ${ $self->{"_WORKDIR"} }; - my $file = $self->{FILE}; - my $arcfile = $self->{ARCFILE} || $file; - - my $archive_file = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - my $workfile = $workdir . $Dir_Sep . $file; - push @param, $archive_file, $workfile; - unshift @param, "-q" if ${ $self->{"_QUIET"} }; # quiet mode - - # run program - croak "co program $coprog not found" unless -e $coprog; - croak "co program $coprog not executable" unless -x $coprog; - system($coprog, @param) == 0 or croak "$!"; - - # re-parse RCS file and clear comments hash - _parse_rcs_header($self); - $self->{COMMENTS} = undef; -} - -#------------------------------------------------------------------ -# comments -#------------------------------------------------------------------ -sub comments { - my $self = shift; - - if (not defined $self->{COMMENTS}) { - _parse_rcs_body($self); - } - - return %{$self->{COMMENTS}}; -} - -#------------------------------------------------------------------ -# daterev -# -# Returns revisions which were created before a specified date. -# -# Method takes one or six arguments. -# -# If one argument, then argument is date number. -# -# If six arguments, then year (4 digit year), month (1-12), day -# of month (1-31), hour (0-23), minute (0-59) and second (0-59). -#------------------------------------------------------------------ -sub daterev { - - my $self = shift; - my $target_time; - - # validate arguments - unless (@_ == 1 or @_ == 6) { - croak "daterev must have either 1 or 6 arguments"; - } - - # string date passed - if (@_ == 6) { - my($year, $mon, $mday, $hour, $min, $sec) = @_; - - if($year !~ /^\d{4}$/) { - croak "year (1st param) must be 4 digit number"; - } - - $mon--; # convert to 0-11 range - $target_time = timegm($sec, $min, $hour, $mday, $mon, $year); - } - - # system date passed - else { - $target_time = shift; - - if ($target_time !~ /^\d+$/) { - croak "system date must be an integer"; - } - } - - if (not defined $self->{DATE}) { - _parse_rcs_header($self); - } - - my @revisions = (); - my %dates; - my %dates_hash = %{$self->{DATE}}; - - my $revision; - foreach $revision (keys %dates_hash) { - my $date = $dates_hash{$revision}; - $dates{$date}{$revision} = 1; - } - - my $date; - foreach $date (reverse sort keys %dates) { - foreach $revision (keys %{ $dates{$date} }) { - push @revisions, $revision if $date <= $target_time; - } - } - - return wantarray ? @revisions : $revisions[0]; -} - -#------------------------------------------------------------------ -# dates -# Return a hash of revision dates, keyed on revision, when called -# in list mode. -# Return the most recent date when called in scalar mode. -# -# RCS stores dates in GMT. -# The date values are system dates. -#------------------------------------------------------------------ -sub dates { - my $self = shift; - - if (not defined $self->{DATE}) { - _parse_rcs_header($self); - } - - my %DatesHash = %{$self->{DATE}}; - my @dates_list = sort {$b<=>$a} values %DatesHash; - my $MostRecent = $dates_list[0]; - - return wantarray ? %DatesHash : $MostRecent; -} - -#------------------------------------------------------------------ -# file -# Name of working file. -#------------------------------------------------------------------ -sub file { - my $self = shift; - if (@_) { $self->{FILE} = shift } - return $self->{FILE}; -} - -#------------------------------------------------------------------ -# head -# Return the head revision. -#------------------------------------------------------------------ -sub head { - my $self = shift; - - if (not defined $self->{HEAD}) { - _parse_rcs_header($self); - } - return $self->{HEAD}; -} - -#------------------------------------------------------------------ -# lock -# Return user who has file locked. -#------------------------------------------------------------------ -sub lock { - my $self = shift; - - if (not defined $self->{LOCK}) { - _parse_rcs_header($self); - } - return $self->{LOCK}; -} - -#------------------------------------------------------------------ -# quiet -# Set or un-set RCS quiet mode. -#------------------------------------------------------------------ -sub quiet { - my $self = shift; - - # called as object method - if (ref $self) { - - # set/un-set quiet mode - if (@_) { - my $mode = shift; - croak "Passed parameter must be either '0' or '1'" - unless $mode == 0 or $mode == 1; - ${ $self->{"_QUIET"} } = $mode; - return ${ $self->{"_QUIET"} }; - } - - # access quiet mode - else { - return ${ $self->{"_QUIET"} }; - } - } - - # called as class method - else { - - # set/un-set quiet mode - if (@_) { - my $mode = shift; - croak "Passed parameter must be either '0' or '1'" - unless $mode == 0 or $mode == 1; - $Quiet = $mode; - return $Quiet; - } - - # access quiet mode - else { - return $Quiet; - } - } -} - -#------------------------------------------------------------------ -# rcs -# Execute RCS 'rcs' program. -# Make archive filename same as working filename unless -# specifically set. -#------------------------------------------------------------------ -sub rcs { - my $self = shift; - my @param = @_; - - my $rcsprog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'rcs' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $workdir = ${ $self->{"_WORKDIR"} }; - my $file = $self->{FILE}; - my $arcfile = $self->{ARCFILE} || $file; - - my $archive_file = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - my $workfile = $workdir . $Dir_Sep . $file; - push @param, $archive_file, $workfile; - unshift @param, "-q" if ${ $self->{"_QUIET"} }; # quiet mode - - # run program - croak "rcs program $rcsprog not found" unless -e $rcsprog; - croak "rcs program $rcsprog not executable" unless -x $rcsprog; - system($rcsprog, @param) == 0 or croak "$?"; - - # re-parse RCS file and clear comments hash - _parse_rcs_header($self); - $self->{COMMENTS} = undef; -} - -#------------------------------------------------------------------ -# rcsclean -# Execute RCS 'rcsclean' program. -#------------------------------------------------------------------ -sub rcsclean { - my $self = shift; - my @param = @_; - - my $rcscleanprog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'rcsclean' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $workdir = ${ $self->{"_WORKDIR"} }; - my $file = $self->{FILE}; - my $arcfile = $self->{ARCFILE} || $file; - - my $archive_file = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - my $workfile = $workdir . $Dir_Sep . $file; - push @param, $archive_file, $workfile; - - # run program - croak "rcsclean program $rcscleanprog not found" unless -e $rcscleanprog; - croak "rcsclean program $rcscleanprog not executable" unless -x $rcscleanprog; - system($rcscleanprog, @param) == 0 or croak "$?"; - - # re-parse RCS file and clear comments hash - _parse_rcs_header($self); - $self->{COMMENTS} = undef; -} - -#------------------------------------------------------------------ -# rcsdiff -# Execute RCS 'rcsdiff' program. -# Calling in list context returns the output of rcsdiff, while -# calling in scalar context returns the return status of the -# rcsdiff program. -#------------------------------------------------------------------ -sub rcsdiff { - my $self = shift; - my @param = @_; - - my $rcsdiff_prog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'rcsdiff' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $arcfile = $self->{ARCFILE} || $self->{FILE}; - $arcfile = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - my $workfile = $self->workdir . $Dir_Sep . $self->file; - - # un-taint parameter string - unshift @param, "-q" if ${ $self->{"_QUIET"} }; # quiet mode - my $param_str = join(' ', @param); - $param_str =~ s/([\w-]+)/$1/g; - - croak "rcsdiff program $rcsdiff_prog not found" unless -e $rcsdiff_prog; - croak "rcsdiff program $rcsdiff_prog not executable" unless -x $rcsdiff_prog; - open(DIFF, "$rcsdiff_prog $param_str $arcfile $workfile |"); - my @diff_output = <DIFF>; - - # rcsdiff returns exit status 0 for no differences, 1 for differences, - # and 2 for error condition. - close DIFF; - my $status = $?; - croak "$rcsdiff_prog failed" if $status == 2; - return wantarray ? @diff_output : $status; -} - -#------------------------------------------------------------------ -# rcsdir -# Location of 'RCS' archive directory. -#------------------------------------------------------------------ -sub rcsdir { - my $self = shift; - - # called as object method - if (ref $self) { - if (@_) { ${ $self->{"_RCSDIR"} } = shift } - return ${ $self->{"_RCSDIR"} }; - } - - # called as class method - else { - if (@_) { $Rcs_Dir = shift } - return $Rcs_Dir; - } -} - -#------------------------------------------------------------------ -# revdate -# Return the revision date of an RCS revision. -# If revision is not provided, default to 'head' revision. -# -# RCS stores dates in GMT. This method will return dates relative -# to the local time zone. -#------------------------------------------------------------------ -sub revdate { - my $self = shift; - - if (not defined $self->{DATE}) { - _parse_rcs_header($self); - } - my $revision = shift || $self->{HEAD}; - - # dereference date hash - my %date_array = %{ $self->{DATE} }; - my $date_str = $date_array{$revision}; - - return wantarray ? localtime($date_str) : $date_str; -} - -#------------------------------------------------------------------ -# revisions -#------------------------------------------------------------------ -sub revisions { - my $self = shift; - - if (not @{ $self->{REVISIONS} }) { - _parse_rcs_header($self); - } - - # dereference revisions list - my @revisions = @{ $self->{REVISIONS} }; - - @revisions; -} - -#------------------------------------------------------------------ -# rlog -# Execute RCS 'rlog' program. -# Make archive filename same as working filename unless -# specifically set. -#------------------------------------------------------------------ -sub rlog { - my $self = shift; - my @param = @_; - - my $rlogprog = ${ $self->{"_BINDIR"} } . $Dir_Sep . 'rlog' . $Exe_Ext; - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $arcfile = $self->{ARCFILE} || $self->{FILE}; - - # un-taint parameter string - my $param_str = join(' ', @param); - $param_str =~ s/([\w-]+)/$1/g; - - my $archive_file = $rcsdir . $Dir_Sep . $arcfile . ${ $self->{"_ARCEXT"} }; - croak "rlog program $rlogprog not found" unless -e $rlogprog; - croak "rlog program $rlogprog not executable" unless -x $rlogprog; - open(RLOG, "$rlogprog $param_str $archive_file |"); - - my @logoutput = <RLOG>; - close RLOG; - croak "$rlogprog failed" if $?; - @logoutput; -} - -#------------------------------------------------------------------ -# state -# If revision is not provided, default to 'head' revision -#------------------------------------------------------------------ -sub state { - my $self = shift; - - if (not defined $self->{STATE}) { - _parse_rcs_header($self); - } - my $revision = shift || $self->{HEAD}; - - # dereference author hash - my %state_array = %{ $self->{STATE} }; - - return $state_array{$revision}; -} - -#------------------------------------------------------------------ -# symbol -# If revision is not provided, default to 'head' revision -#------------------------------------------------------------------ -sub symbol { - my $self = shift; - - if (not defined $self->{SYMBOLS}) { - _parse_rcs_header($self); - } - my $revision = shift || $self->{HEAD}; - - # dereference symbols hash - my %sym_array = %{ $self->{SYMBOLS} }; - - return '' if not defined $sym_array{$revision}; - - my @symbols = @{ $sym_array{$revision} }; - - # return only first array element if user wants scalar - return wantarray ? @symbols : $symbols[0]; -} - -#------------------------------------------------------------------ -# symbols -# Returns hash of all revisions keyed on symbol defined against file. -#------------------------------------------------------------------ -sub symbols { - my $self = shift; - - if(not defined $self->{SYMBOLS}) { - _parse_rcs_header($self); - } - - my %symbols; - - # loop through each revision - my $rev; - foreach $rev (@{ $self->{REVISIONS} }) { - my $sym; - foreach $sym (@{ $self->{SYMBOLS}->{$rev} }) { - $symbols{$sym} = $rev; - } - } - return %symbols; -} - -#------------------------------------------------------------------ -# symrev -# 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. -#------------------------------------------------------------------ -sub symrev { - my $self = shift; - my $sym = shift; - if(! defined $sym) { - croak "You must supply a symbol to symrev"; - } - - if (not defined $self->{SYMBOLS}) { - _parse_rcs_header($self); - } - - my $ret_rev = 0; - my %symbols; - - # loop through each revision - my $rev; - REV_LOOP: - foreach $rev (@{ $self->{REVISIONS} }) { - # loop through each symbol defined against - # this revision - my $s; - foreach $s (@{ $self->{SYMBOLS}->{$rev} }) { - - # store each revision matching the pattern - if (wantarray) { - $symbols{$s} = $rev if $s =~ /$sym/; - } - - # if it's the one we're looking for, we can - # quit as we've found the revision we want - else { - if($s eq $sym) { - $ret_rev = $rev; - last REV_LOOP; - } - } - } - } - - return wantarray ? %symbols : $ret_rev; -} - -#------------------------------------------------------------------ -# workdir -# Location of working directory. -#------------------------------------------------------------------ -sub workdir { - my $self = shift; - - # called as object method - if (ref $self) { - if (@_) { ${ $self->{"_WORKDIR"} } = shift } - return ${ $self->{"_WORKDIR"} }; - } - - # called as class method - else { - if (@_) { $Work_Dir = shift } - return $Work_Dir; - } -} - -#------------------------------------------------------------------ -# _parse_rcs_body -# Private function -#------------------------------------------------------------------ -sub _parse_rcs_body { - - my $self = shift; - local $_; - - my %comments; - - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $file = $self->{FILE}; - my $rcs_file = $rcsdir . $Dir_Sep . $file . ${ $self->{"_ARCEXT"} }; - - # parse RCS archive file - open RCS_FILE, $rcs_file or croak "Unable to open $rcs_file"; - - # skip header info and get description - DESC: while (<RCS_FILE>) { - if (/^desc$/) { - $comments{0} = ''; - $_ = <RCS_FILE>; # read first line - s/^\@//; # remove leading '@' - while (1) { - last DESC if /^\@$/; - s/\@\@/\@/g; # RCS replaces single '@' with '@@' - $comments{0} .= $_; - $_ = <RCS_FILE>; - } - } - } - - # parse revision comments - my $revision; - REVISION: while (<RCS_FILE>) { - if (/^[\d\.]+$/) { - chomp($revision = $_); - $_ = <RCS_FILE>; - if (/^log$/) { - $comments{$revision} = ''; - $_ = <RCS_FILE>; # read first line - s/^\@//; # remove leading '@' - while (1) { - next REVISION if /^\@$/; - s/\@\@/\@/g; # RCS replaces single '@' with '@@' - $comments{$revision} .= $_; - $_ = <RCS_FILE>; - } - } - } - } - - # loop through 'text' section to avoid capturing bogus info - continue { - if (/^text$/) { # 'text' tag should always be there, but check anyway - while (<RCS_FILE>) { - s/\@\@//g; # RCS replaces single '@' with '@@' - last if /\@$/ - } - } - } - - close RCS_FILE; - $self->{COMMENTS} = \%comments; -} - -#------------------------------------------------------------------ -# _parse_rcs_header -# Private function -# Directly parse the RCS archive file. -#------------------------------------------------------------------ -sub _parse_rcs_header { - - my $self = shift; - local $_; - - my ($head, $lock); - my (@access_list, @revisions); - my (%author, %date, %state, %symbols); - - my $rcsdir = ${ $self->{"_RCSDIR"} }; - my $file = $self->{FILE}; - my $rcs_file = $rcsdir . $Dir_Sep . $file . ${ $self->{"_ARCEXT"} }; - - # parse RCS archive file - open RCS_FILE, $rcs_file - or croak "Unable to open $rcs_file"; - while (<RCS_FILE>) { - next if /^\s*$/; # skip blank lines - last if /^desc$/; # end of header info - - # get head revision - if (/^head\s/) { - ($head) = /^head\s+(.*?);$/; - next; - } - - # get access list - if (/^access$/) { - while (<RCS_FILE>) { - chomp; - s/\s//g; # remove all whitespace - push @access_list, (split(/;/))[0]; - last if /;$/; - } - next; - } - - # get locker - # get symbols - if (/^symbols$/) { - while (<RCS_FILE>) { - chomp; - s/\s//g; # remove all whitespace - my ($sym, $rev) = split(/:/); - $rev =~ s/;$//; - push @{ $symbols{$rev} }, $sym; - last if /;$/; - } - next; - } - - # get locker - if (/^locks/) { - - # file not locked - if (/strict/) { - $lock = ''; - next; - } - - # get user who has file locked - my $next_line = <RCS_FILE>; # read next line - ($lock) = $next_line =~ m/^\s*(\w+):/; - next; - } - - # get all revisions - if (/^\d+\.\d+/) { - chomp; - push @revisions, $_; - - # get author, state and date of each revision - my $next_line = <RCS_FILE>; - chop(my $author = (split(/\s+/, $next_line))[3]); - chop(my $state = (split(/\s+/, $next_line))[5]); - chop(my $date = (split(/\s+/, $next_line))[1]); - - # store date as date number - my ($year, $mon, $mday, $hour, $min, $sec) = split(/\./, $date); - $mon--; # convert to 0-11 range - my @date = ($sec,$min,$hour,$mday,$mon,$year); - - # store value in hash using revision as key - $author{$_} = $author; - $state{$_} = $state; - $date{$_} = timegm(@date); - } - } - close RCS_FILE; - - $self->{HEAD} = $head; - $self->{LOCK} = $lock; - $self->{ACCESS} = \@access_list; - $self->{REVISIONS} = \@revisions; - $self->{AUTHOR} = \%author; - $self->{DATE} = \%date; - $self->{STATE} = \%state; - $self->{SYMBOLS} = \%symbols; -} - -1; - -__END__ - -=head1 NAME - -Rcs - Perl Object Class for Revision Control System (RCS). - -=head1 SYNOPSIS - - use Rcs; - -=head1 DESCRIPTION - -This Perl module provides an object oriented interface to access -B<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. - -=head2 OBJECT CONSTRUCTOR - -The B<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; - -=head2 CLASS METHODS - -Besides the object constructor, there are three class methods provided -which effect any newly created objects. - -The B<arcext> method sets the RCS archive extension, which is ',v' by -default. - - # set/unset RCS archive extension - Rcs->arcext(''); # set no archive extension - Rcs->arcext(',v'); # set archive extension to ',v' - $arc_ext = Rcs->arcext(); # get current archive extension - -The B<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 B<quiet> method sets/unsets the quiet mode for the RCS executables. -Quiet mode is set by 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->arcext(''); - $obj->bindir('/usr/bin'); - $obj->quiet(0); - -=head2 OBJECT ATTRIBUTE METHODS - -These methods set the attributes of the RCS object. - -The B<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 B<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 -RCS archive extension (default ',v') is automatically added to the filename. - - $obj->arcfile('principle_mcvicker.pl'); - -The B<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 B<rcsdir> methods set the path of the RCS archive directory. If not -specified, default path is './RCS'. - - $obj->rcsdir('/usr/local/archive'); - -=head2 RCS PARSE METHODS - -This class provides methods to directly parse the RCS archive file. - -The B<access> method returns a list of all user on the access list. - - @access_list = $obj->access; - -The B<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 B<head> method returns the head revision. - - $head = $obj->head; - -The B<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 B<revisions> method returns a list of all revisions of archive file. - - @revisions = $obj->revisions; - -The B<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 B<symbol> method returns the symbol(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 a 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 B<symbols> method returns a hash, keyed by symbol, of all of the revisions -associated with the file. - - %symbols = $obj->symbols; - foreach $sym (keys %symbols) { - $rev = $symbols{$sym}; - } - -The B<revdate> 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. - - # scalar mode - $scalar_date = $obj->revdate; - print "Scalar date number = $scalar_date\n"; - $date_str = localtime($scalar_date); - print "Scalar date string = $date_str\n"; - - # list mode - @list_date = $obj->revdate; - print "List date = @list_date\n"; - -The B<dates> 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. - - # list mode - %DatesHash = obj->dates; - @dates_list = sort {$b<=>$a} values %DatesHash; - $MostRecent = $dates_list[0]; - - # scalar mode - $most_recent = $obj->dates; - print "Most recent date = $most_recent\n"; - $most_recent_str = localtime($most_recent); - print "Most recent date string = $most_recent_str\n"; - -The B<symrev> 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. - - # gets revision that has 'MY_SYMBOL' defined against it - $rev = $obj->symrev('MY_SYMBOL'); - -The B<daterev> 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. - - # one argument, date number - # gets revisions created before Sun Sep 6 22:23:47 1998 - @revs = $obj->daterev(841436420); - - # six argument - # gets revisions created before 25th June 1998 16:45:30 - @revs = $obj->daterev(1998, 6, 25, 16, 45, 30); - -The B<comments> method returns a hash of revision comments, keyed on revision. -A key value of 0 returns the description. - - %comments = $obj->comments; - $description = $comments{0}; - $comment_1_3 = $comments{'1.3'}; - -=head2 RCS SYSTEM METHODS - -These methods invoke the RCS system utilities. - -The B<ci> method calls the RCS ci program. - - # check in, and then check out in unlocked state - $obj->ci('-u'); - -The B<co> method calls the RCS co program. - - # check out in locked state - $obj->co('-l'); - -The B<rcs> method calls the RCS rcs program. - - # lock file - $obj->rcs('-l'); - -The B<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 B<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 B<rcsclean> method calls the RCS rcsclean program. - - # remove working file - $obj->rcsclean; - - -=head1 EXAMPLES - -=head2 CREATE ACCESS LIST - -Using method B<rcs> with the B<-a> switch allows you to add users to -the access list of an RCS archive file. - - use Rcs; - $obj = Rcs->new; - - $obj->rcsdir("./project_tree/archive"); - $obj->workdir("./project_tree/src"); - $obj->file("cornholio.pl"); - -Methos B<rcs> invokes the RCS utility rcs with the same parameters. - - @users = qw(beavis butthead); - $obj->rcs("-a@users"); - -Calling method B<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"; - - -=head2 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 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"; - } - -=head2 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 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 B<-u> switch. This will check in the file, and will then -check out the file in an unlocked state. The B<-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; - -=head2 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 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'); - -=head2 RCSDIFF - -Method B<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'); - -=head2 RCSCLEAN - -Method B<rcsclean> will remove an unlocked working file. - - use 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; - -=head1 AUTHOR - -Craig Freter, E<lt>F<craig@freter.com>E<gt> - -=head1 CONTRIBUTORS - -David Green, E<lt>F<greendjf@cvhp152.gpt.co.uk>E<gt> - -Jamie O'Shaughnessy, E<lt>F<jamie@thanatar.demon.co.uk>E<gt> - -=head1 COPYRIGHT - -Copyright (C) 1997,1998 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. - -=cut - |
