ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/URL_cvs.pm
Revision: 1.4
Committed: Wed Sep 29 07:28:58 1999 UTC (25 years, 7 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.3: +3 -2 lines
Log Message:
URL:: mods

File Contents

# User Rev Content
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 williamc 1.4 package URL::URL_cvs;
12 williamc 1.1 require 5.001;
13     use Utilities::CVSmodule;
14 williamc 1.4 use URL::URL_base;
15 williamc 1.1 use Carp;
16 williamc 1.4 @ISA = qw(URL::URL_base);
17 williamc 1.1
18     sub init {
19     my $self=shift;
20     $self->{cvsco}="co";
21 williamc 1.3 $self->{dirname}="";
22 williamc 1.1 }
23    
24     sub setbase {
25     my $self=shift;
26     my $varhash=shift;
27    
28     my $base=$$varhash{'base'};
29     my $auth=$$varhash{'auth'};
30    
31     # a new cvs object
32     $self->{cvsobject}=CVSmodule->new();
33     $self->{cvsobject}->set_base($base);
34     $self->{cvsobject}->set_auth($auth);
35     if ( exists $$varhash{'user'} ) {
36     $self->{cvsobject}->set_user($$varhash{'user'});
37     }
38     if ( exists $$varhash{'passkey'} ) {
39     $self->{cvsobject}->set_passkey($$varhash{'passkey'});
40     }
41     if ( exists $$varhash{'method'} ) {
42     $self->{cvsco}=$$varhash{'method'};
43     }
44     # Alternative dir name to co to
45     if ( exists $$varhash{'name'} ) {
46     $self->{dirname}=$$varhash{'name'};
47     }
48     }
49    
50     sub unsetbase {
51     my $self=shift;
52     delete $self->{cvsobject};
53     }
54    
55     #
56     # url module?version
57     #
58     sub get {
59     my $self=shift;
60     my $url=shift;
61    
62     my $cvscmd;
63     my $module="";
64     my $version="";
65 williamc 1.3 my $rv;
66 williamc 1.1
67     # Split up our url into its components
68     if ( $url=~/\?/ ) {
69     ($module, $version)= split /\?/, $url;
70     }
71     else {
72     $module=$url;
73     }
74    
75     if ( $version ne "" ) {
76     $cvscmd=$self->{cvsco}." -r $version";
77     }
78     else {
79     $cvscmd=$self->{cvsco};
80     }
81     if ( $self->{dirname} ne "" ) {
82     $cvscmd=$cvscms." -d ".$self->{dirname};
83 williamc 1.3 $rv=$self->{dirname};
84     }
85     else {
86     $rv=$self->getfilefrompath($url);
87 williamc 1.1 }
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 williamc 1.3 $rv="";
95 williamc 1.1 }
96     else {
97     $self->{cvsobject}->invokecvs($cvscmd, $module);
98     }
99 williamc 1.3 return $rv;
100 williamc 1.1 }