|
NAME"VCS::CVS" - Provide a simple interface to CVS (the Concurrent Versions System).SYNOPSIS#!/usr/gnu/bin/perl -w use strict; use VCS::CVS; my($history) = 1; my($initialMsg) = 'Initial version'; my($noChange) = 1; my($nullTag) = ''; my($permissions) = 0775; # But not '0775'! my($project) = 'project'; my($projectSource) = 'projectSource'; my($raw) = 0; my($readOnly) = 0; my($releaseTag) = 'release_0.00'; my($vendorTag) = 'vendorTag'; my($verbose) = 1; # Note the anonymous hash in the next line, new as of V 1.10. my($cvs) = VCS::CVS -> new({ 'project' => $project, 'raw' => $raw, 'verbose' => $verbose, 'permissions' => $permissions, 'history' => $history}); $cvs -> createRepository(); $cvs -> populate($projectSource, $vendorTag, $releaseTag, $initialMsg); $cvs -> checkOut($readOnly, $nullTag, $project); print join("\n", @{$cvs -> update($noChange)}); print "\n"; print join("\n", @{$cvs -> history()}); exit(0); DESCRIPTIONThe "VCS::CVS" module provides an OO interface to CVS.VCS - Version Control System - is the prefix given to each Perl module which deals with some sort of source code control system. I have seen CVS corrupt binary files, even when run with CVS's binary option -kb. So, since CVS doesn't support binary files, neither does VCS::CVS. Stop press: CVS V 1.10 (with RCS 5.7) supports binary files. Subroutines whose names start with a '_' are not normally called by you. You need to be clear in your mind about the 4 directories involved:
Note: You cannot have a directory called CVS in your home directory. That's just asking for trouble. INSTALLATIONYou install "VCS::CVS", as you would install any perl module library, by running these commands:perl Makefile.PL make make test make install If you want to install a private copy of "VCS::CVS" in your home directory, then you should try to produce the initial Makefile with something like this command: perl Makefile.PL LIB=~/perl or perl Makefile.PL LIB=C:/Perl/Site/Lib If, like me, you don't have permission to write man pages into unix system directories, use: make pure_install instead of make install. This option is secreted in the middle of p 414 of the second edition of the dromedary book. WARNING re CVS bugsThe following are my ideas as to what constitutes a bug in CVS:
WARNING re test environmentThis code has only been tested under Unix. Sorry.WARNING re project names 'v' directory namesI assume your copy of the repository was checked out into a directory with the same name as the project, since I do a 'cd $HOME/$project' before running 'cvs status', to see if your copy is up-to-date. This is because some activity is forbibben unless your copy is up-to-date. Typical cases of this include:
WARNING re shell interventionSome commands cause the shell to become involved, which, under Unix, will read your .cshrc or whatever, which in turn may set CVSROOT to something other than what you set it to before running your script. If this happens, panic...Actually, I think I've eliminated such cases. You hope so. WARNING re Perl bugAs always, be aware that these 2 lines mean the same thing, sometimes:
The problem is the spaces around the ->. Inside double quotes, "...", the first space stops the dereference taking place. Outside double quotes the scanner correctly associates the $self token with the {'thing'} token. I regard this as a bug. addDirectory($dir, $subDir, $message)Add an existing directory to the project.$dir can be a full path, or relative to the CWD. addFile($dir, $file, $message)Add an existing file to the project.$dir can be a full path, or relative to the CWD. checkOut($readOnly, $tag, $dir)Prepare & perform 'cvs checkout'.You call checkOut, and it calls _checkOutDontCallMe.
The value of $raw used in the call to new influences the handling of $tag:
$dir can be a full path, or relative to the CWD. commit($message)Commit changes.Called as appropriate by addFile, removeFile and removeDirectory, so you don't need to call it. createRepository()Create a repository, using the current $CVSROOT.This involves creating these files:
Notes:
getTags()Return a reference to a list of tags.See also: the $raw option to new(). "getTags" does not take a project name because tags belong to the repository as a whole, not to a project. history({})Report details from the history log, $CVSROOT/CVSROOT/history.You must have used new({'history' => 1}), or some other mechanism, to create the history file, before CVS starts logging changes into the history file. The anonymous hash takes any parameters 'cvs history' takes, and joins them with a single space. Eg: $cvs -> history(); $cvs -> history({'-e' => ''}); $cvs -> history({'-xARM' => ''}); $cvs -> history({'-u' => $ENV{'LOGNAME'}, '-x' => 'A'}); but not $cvs -> history({'-xA' => 'M'}); because it doesn't work. new({})Create a new object. See the synopsis.The anonymous hash takes these parameters, of which 'project' is the only required one.
populate($sourceDir, $vendorTag, $releaseTag, $message)Import an existing directory structure. But, (sub) import is a reserved word.Use this to populate a repository for the first time. The value used for $vendorTag is not important; CVS discards it. The value used to $releaseTag is important; CVS discards it (why?) but I force it to be the first tag in $CVSROOT/CVSROOT/val-tags. Thus you should supply a meaningful value. Thus 'release_0_00' is strongly, repeat strongly, recommended. The value of $raw used in the call to new influences the handling of $tag:
removeDirectory($dir)Remove a directory from the project.This deletes the directory (and all its files) from your working copy of the repository, as well as deleting them from the repository. Warning: $dir will have $CVSROOT and $HOME prepended by this code. Ie: $dir starts from - but excludes - your home directory (assuming, of course, you've checked out into your home directory...). You can't remove the current directory, or a parent. removeFile($dir, $file, $message)Remove a file from the project.This deletes the file from your working copy of the repository, as well as deleting it from the repository. $dir can be a full path, or relative to the CWD. $file is relative to $dir. runOrCroak()The standard way to run a system command and report on the result.setTag($tag)Tag the repository.You call setTag, and it calls _setTag. The value of $raw used in the call to new influences the handling of $tag:
stripCVSDirs($dir)Delete all CVS directories and files from a copy of the repository.Each user directory contains a CVS sub-directory, which holds 3 files:
Zap 'em. status()Run cvs status.Return a reference to a list of lines. Only called by upToDate(), but you may call it. update($noChange)Run 'cvs "-q" ["-n"] update', returning a reference to a list of lines. Each line will start with one of [UARMC?], as per the CVS docs.$cvs -> update(1) is a good way to get a list of uncommited changes, etc.
upToDate()
_checkOutDontCallMe($readOnly, $tag, $dir)Checkout a current copy of the project.You call checkOut, and it calls this.
_fixTag($tag)Fix a tag which CVS failed to add.Warning: $tag must be in CVS format: release_1_23, not release_1.23. _mkpathOrCroak($self, $dir)There is no need for you to call this._readFile($file)Return a reference to a list of lines.There is no need for you to call this. _setTag($tag)Tag the current version of the project.Warning: $tag must be in CVS format: release_1_23, not release_1.23. You call setTag and it calls this. _validateObject($tag, $file, $mustBeAbsent)Validate an entry in one of the CVS files 'module' or 'val-tags'.Warning: $tag must be in CVS format: release_1_23, not release_1.23. AUTHOR"VCS::CVS" was written by Ron Savage <ron@savage.net.au> in 1998.LICENCEAustralian copyright (c) 1998-2002 Ron Savage.All Programs of mine are 'OSI Certified Open Source Software'; you can redistribute them and/or modify them under the terms of The Artistic License, a copy of which is available at: http://www.opensource.org/licenses/index.html
Visit the GSP FreeBSD Man Page Interface. |