1 |
williamc |
1.1 |
#
|
2 |
|
|
# standard url interface for cvs
|
3 |
|
|
#
|
4 |
|
|
#Interface
|
5 |
|
|
#-------------
|
6 |
|
|
# new() :
|
7 |
|
|
# setbase($type) :
|
8 |
|
|
# unsetbase() :
|
9 |
williamc |
1.2 |
# get(url) :
|
10 |
williamc |
1.1 |
|
11 |
|
|
package URL_cvs;
|
12 |
|
|
require 5.001;
|
13 |
|
|
use Utilities::CVSmodule;
|
14 |
|
|
use Carp;
|
15 |
|
|
|
16 |
|
|
sub new {
|
17 |
|
|
my $class=shift;
|
18 |
|
|
$self={};
|
19 |
|
|
bless $self, $class;
|
20 |
|
|
$self->init($cache);
|
21 |
|
|
return $self;
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
sub init {
|
25 |
|
|
my $self=shift;
|
26 |
|
|
$self->{cvsco}="co";
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
sub setbase {
|
30 |
|
|
my $self=shift;
|
31 |
|
|
my $varhash=shift;
|
32 |
|
|
|
33 |
|
|
my $base=$$varhash{'base'};
|
34 |
|
|
my $auth=$$varhash{'auth'};
|
35 |
|
|
|
36 |
|
|
# a new cvs object
|
37 |
|
|
$self->{cvsobject}=CVSmodule->new();
|
38 |
|
|
$self->{cvsobject}->set_base($base);
|
39 |
|
|
$self->{cvsobject}->set_auth($auth);
|
40 |
|
|
if ( exists $$varhash{'user'} ) {
|
41 |
|
|
$self->{cvsobject}->set_user($$varhash{'user'});
|
42 |
|
|
}
|
43 |
|
|
if ( exists $$varhash{'passkey'} ) {
|
44 |
|
|
$self->{cvsobject}->set_passkey($$varhash{'passkey'});
|
45 |
|
|
}
|
46 |
|
|
if ( exists $$varhash{'method'} ) {
|
47 |
|
|
$self->{cvsco}=$$varhash{'method'};
|
48 |
|
|
}
|
49 |
|
|
# Alternative dir name to co to
|
50 |
|
|
if ( exists $$varhash{'name'} ) {
|
51 |
|
|
$self->{dirname}=$$varhash{'name'};
|
52 |
|
|
}
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
sub unsetbase {
|
56 |
|
|
my $self=shift;
|
57 |
|
|
delete $self->{cvsobject};
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
#
|
61 |
|
|
# url module?version
|
62 |
|
|
#
|
63 |
|
|
sub get {
|
64 |
|
|
my $self=shift;
|
65 |
|
|
my $url=shift;
|
66 |
|
|
|
67 |
|
|
my $cvscmd;
|
68 |
|
|
my $module="";
|
69 |
|
|
my $version="";
|
70 |
|
|
|
71 |
|
|
# Split up our url into its components
|
72 |
|
|
if ( $url=~/\?/ ) {
|
73 |
|
|
($module, $version)= split /\?/, $url;
|
74 |
|
|
}
|
75 |
|
|
else {
|
76 |
|
|
$module=$url;
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
if ( $version ne "" ) {
|
80 |
|
|
$cvscmd=$self->{cvsco}." -r $version";
|
81 |
|
|
}
|
82 |
|
|
else {
|
83 |
|
|
$cvscmd=$self->{cvsco};
|
84 |
|
|
}
|
85 |
|
|
if ( $self->{dirname} ne "" ) {
|
86 |
|
|
$cvscmd=$cvscms." -d ".$self->{dirname};
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
#
|
90 |
|
|
# Check to see we have a server and if so attempt the checkout
|
91 |
|
|
#
|
92 |
|
|
if ( ! defined $self->{cvsobject} ) {
|
93 |
|
|
print "urlhandler error: undefined cvs server for $module\n";
|
94 |
|
|
}
|
95 |
|
|
else {
|
96 |
|
|
$self->{cvsobject}->invokecvs($cvscmd, $module);
|
97 |
|
|
}
|
98 |
|
|
}
|