2000-09-18 20:54:48 +00:00
|
|
|
|
#!perl -w
|
2000-10-25 22:20:22 +00:00
|
|
|
|
package Moz::MacCVS;
|
2000-09-18 20:54:48 +00:00
|
|
|
|
|
2000-10-25 22:20:22 +00:00
|
|
|
|
# package Mac::Apps::MacCVS; this should really be the name of the package
|
2000-09-18 20:54:48 +00:00
|
|
|
|
# but due to our directory hierarchy in mozilla, I am not doing it
|
|
|
|
|
|
|
|
|
|
require 5.004;
|
2000-10-25 22:20:22 +00:00
|
|
|
|
require Exporter;
|
2000-09-18 20:54:48 +00:00
|
|
|
|
|
|
|
|
|
use strict;
|
2000-10-25 22:20:22 +00:00
|
|
|
|
use Exporter;
|
2000-09-18 20:54:48 +00:00
|
|
|
|
|
2001-05-07 23:50:43 +00:00
|
|
|
|
use vars qw($VERSION @ISA @EXPORT);
|
2000-10-25 22:20:22 +00:00
|
|
|
|
|
2000-09-18 20:54:48 +00:00
|
|
|
|
use Cwd;
|
2000-10-25 22:20:22 +00:00
|
|
|
|
|
2000-09-18 20:54:48 +00:00
|
|
|
|
use File::Basename;
|
|
|
|
|
|
2001-05-07 23:50:43 +00:00
|
|
|
|
use Mac::StandardFile;
|
|
|
|
|
use Mac::AppleEvents;
|
|
|
|
|
use Mac::AppleEvents::Simple;
|
|
|
|
|
|
|
|
|
|
@ISA = qw(Exporter);
|
|
|
|
|
@EXPORT = qw(new describe checkout update);
|
2000-09-18 20:54:48 +00:00
|
|
|
|
$VERSION = "1.00";
|
|
|
|
|
|
2001-05-07 23:50:43 +00:00
|
|
|
|
# If you want to understand the gobbldeygook that's used to build Apple Events,
|
|
|
|
|
# you should start by reading the AEGizmos documentation.
|
|
|
|
|
|
2000-10-20 01:58:10 +00:00
|
|
|
|
|
2000-09-18 20:54:48 +00:00
|
|
|
|
# Architecture:
|
|
|
|
|
# cvs session object:
|
|
|
|
|
# name - session name
|
|
|
|
|
# session_file - session file
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
|
2001-05-07 23:50:43 +00:00
|
|
|
|
my($last_error) = 0;
|
|
|
|
|
my($gAppSig) = 'Mcvs'; # MacCVS Pro
|
|
|
|
|
|
2000-09-18 20:54:48 +00:00
|
|
|
|
#
|
|
|
|
|
# utility routines
|
|
|
|
|
#
|
|
|
|
|
|
2000-10-25 22:20:22 +00:00
|
|
|
|
|
2001-05-07 23:50:43 +00:00
|
|
|
|
sub _checkForEventError($)
|
2000-09-18 20:54:48 +00:00
|
|
|
|
{
|
2001-05-07 23:50:43 +00:00
|
|
|
|
my($evt) = @_;
|
|
|
|
|
|
|
|
|
|
if ($evt->{ERRNO} != 0)
|
|
|
|
|
{
|
|
|
|
|
print STDERR "Error. Script returned '$evt->{ERROR} (error $evt->{ERRNO})\n";
|
|
|
|
|
$last_error = $evt->{ERRNO};
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1; # success
|
2000-09-18 20:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Session object methods
|
|
|
|
|
#
|
|
|
|
|
|
2000-10-20 01:58:10 +00:00
|
|
|
|
sub new
|
|
|
|
|
{
|
2001-05-07 23:50:43 +00:00
|
|
|
|
my ( $proto, $session_file) = @_;
|
|
|
|
|
my $class = ref($proto) || $proto;
|
|
|
|
|
my $self = {};
|
|
|
|
|
|
|
|
|
|
if ( defined($session_file) && ( -e $session_file) )
|
|
|
|
|
{
|
|
|
|
|
$self->{"name"} = basename( $session_file );
|
|
|
|
|
$self->{"session_file"} = $session_file;
|
|
|
|
|
bless $self, $class;
|
|
|
|
|
return $self;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print STDERR "MacCVS->new cvs file < $session_file > does not exist\n";
|
|
|
|
|
return;
|
|
|
|
|
}
|
2000-09-18 20:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# makes sure that the session is open
|
|
|
|
|
# assertSessionOpen()
|
2000-10-20 01:58:10 +00:00
|
|
|
|
# returns 1 on success
|
|
|
|
|
sub assertSessionOpen()
|
|
|
|
|
{
|
2001-05-07 23:50:43 +00:00
|
|
|
|
my ($self) = shift;
|
|
|
|
|
|
|
|
|
|
$last_error = 0;
|
|
|
|
|
|
|
|
|
|
my($prm) =
|
|
|
|
|
q"'----':obj {form:name, want:type(alis), seld:TEXT(@), from:'null'()}";
|
|
|
|
|
|
|
|
|
|
my($evt) = do_event(qw/aevt odoc/, $gAppSig, $prm, $self->{session_file});
|
|
|
|
|
return _checkForEventError($evt);
|
2000-09-18 20:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# prints the cvs object, used mostly for debugging
|
2001-05-07 23:50:43 +00:00
|
|
|
|
sub describe
|
2000-10-20 01:58:10 +00:00
|
|
|
|
{
|
2001-05-07 23:50:43 +00:00
|
|
|
|
my($self) = shift;
|
|
|
|
|
$last_error = 0;
|
|
|
|
|
print "MacCVS:: name: ", $self->{name}, " session file: ", $self->{session_file}, "\n";
|
2000-09-18 20:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# checkout( self, module, revision, date)
|
|
|
|
|
# MacCVS checkout command
|
2000-10-20 01:58:10 +00:00
|
|
|
|
# returns 1 on success.
|
|
|
|
|
sub checkout()
|
2000-09-18 20:54:48 +00:00
|
|
|
|
{
|
2001-05-07 23:50:43 +00:00
|
|
|
|
my($self, $module, $revision, $date ) = @_;
|
|
|
|
|
unless( defined ($module) ) { $module = ""; } # get rid of the pesky undefined warnings
|
|
|
|
|
unless( defined ($revision) ) { $revision = ""; }
|
|
|
|
|
unless( defined ($date) ) { $date = ""; }
|
|
|
|
|
|
|
|
|
|
$last_error = 0;
|
|
|
|
|
|
|
|
|
|
$self->assertSessionOpen() || die "Error: failed to open MacCVS session file at $self->{session_file}\n";
|
|
|
|
|
|
|
|
|
|
my($revstring) = ($revision ne "") ? $revision : "(none)";
|
|
|
|
|
my($datestring) = ($date ne "") ? $date : "(none)";
|
|
|
|
|
|
|
|
|
|
print "Checking out $module with revision $revstring, date $datestring\n";
|
|
|
|
|
|
|
|
|
|
my($prm) =
|
|
|
|
|
q"'----':obj {form:name, want:type(docu), seld:TEXT(@), from:'null'()}, ".
|
|
|
|
|
q"modl:'TEXT'(@), tagr:'TEXT'(@), tagd:'TEXT'(@) ";
|
|
|
|
|
|
|
|
|
|
my($evt) = do_event(qw/MCvs cout/, $gAppSig, $prm, $self->{name}, $module, $revision, $date);
|
|
|
|
|
return _checkForEventError($evt);
|
2000-09-18 20:54:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-05-07 23:50:43 +00:00
|
|
|
|
|
|
|
|
|
# update( self, branch tag, list of paths)
|
|
|
|
|
# MacCVS udate command
|
|
|
|
|
# returns 1 on success.
|
|
|
|
|
# NOTE: MacCVS Pro does not correctly support this stuff yet (as of version 2.7d5).
|
|
|
|
|
sub update()
|
|
|
|
|
{
|
|
|
|
|
my($self, $branch, $paths ) = @_;
|
|
|
|
|
|
|
|
|
|
$last_error = 0;
|
|
|
|
|
|
|
|
|
|
$self->assertSessionOpen() || die "Error: failed to open MacCVS session file at $self->{session_file}\n";
|
|
|
|
|
|
|
|
|
|
if ($branch eq "HEAD") {
|
|
|
|
|
$branch = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
my($paths_list) = "";
|
|
|
|
|
|
|
|
|
|
my($path);
|
|
|
|
|
foreach $path (@$paths)
|
|
|
|
|
{
|
|
|
|
|
if ($paths_list ne "") {
|
|
|
|
|
$paths_list = $paths_list.", ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$paths_list = $paths_list."<22>".$path."<22>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
my($prm) =
|
|
|
|
|
q"'----':obj {form:name, want:type(docu), seld:TEXT(@), from:'null'()}, ".
|
|
|
|
|
q"tagr:'TEXT'(@), tFls:[";
|
|
|
|
|
|
|
|
|
|
$prm = $prm.$paths_list."]";
|
|
|
|
|
|
|
|
|
|
my($evt) = do_event(qw/MCvs updt/, $gAppSig, $prm, $self->{name}, $branch);
|
|
|
|
|
return _checkForEventError($evt);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2000-10-20 01:58:10 +00:00
|
|
|
|
sub getLastError()
|
|
|
|
|
{
|
2001-05-07 23:50:43 +00:00
|
|
|
|
return $last_error;
|
2000-10-20 01:58:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-09-18 20:54:48 +00:00
|
|
|
|
1;
|
|
|
|
|
=pod
|
|
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
|
|
MacCVS - Interface to MacCVS
|
|
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
2001-05-07 23:50:43 +00:00
|
|
|
|
use MacCVS;
|
|
|
|
|
$session = MacCVS->new( <session_file_path>) || die "cannot create session";
|
|
|
|
|
$session->checkout([module] [revision] [date]) || die "Could not check out";
|
|
|
|
|
|
2000-09-18 20:54:48 +00:00
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
|
|
This is a MacCVS interface for talking to MacCVS Pro client.
|
|
|
|
|
MacCVSSession is the class used to manipulate the session
|
|
|
|
|
|
|
|
|
|
=item new
|
2001-05-07 23:50:43 +00:00
|
|
|
|
MacCVS->new( <cvs session file path>);
|
|
|
|
|
|
|
|
|
|
Creates a new session. Returns undef on failure.
|
2000-09-18 20:54:48 +00:00
|
|
|
|
|
|
|
|
|
=item checkout( <module> [revision] [date] )
|
|
|
|
|
|
2001-05-07 23:50:43 +00:00
|
|
|
|
cvs checkout command. Revision and date are optional
|
|
|
|
|
returns 0 on failure
|
|
|
|
|
|
2000-09-18 20:54:48 +00:00
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
=head1 SEE ALSO
|
|
|
|
|
|
|
|
|
|
=over
|
|
|
|
|
|
|
|
|
|
=item MacCVS Home Page
|
|
|
|
|
|
|
|
|
|
http://www.maccvs.org/
|
|
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
|
|
=head1 AUTHORS
|
|
|
|
|
|
|
|
|
|
Aleks Totic atotic@netscape.com
|
2001-05-07 23:50:43 +00:00
|
|
|
|
Simon Fraser sfraser@netscape.com
|
2000-09-18 20:54:48 +00:00
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
__END__
|