ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/URL_cvs.pm
Revision: 1.5
Committed: Fri Oct 22 10:28:06 1999 UTC (25 years, 6 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.4: +6 -1 lines
Log Message:
Update for new get interface

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.5 # get(url,$dirname) :
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 williamc 1.5 my $dir=shift;
62 williamc 1.1
63     my $cvscmd;
64     my $module="";
65     my $version="";
66 williamc 1.3 my $rv;
67 williamc 1.1
68     # Split up our url into its components
69     if ( $url=~/\?/ ) {
70     ($module, $version)= split /\?/, $url;
71     }
72     else {
73     $module=$url;
74     }
75    
76     if ( $version ne "" ) {
77     $cvscmd=$self->{cvsco}." -r $version";
78     }
79     else {
80     $cvscmd=$self->{cvsco};
81     }
82     if ( $self->{dirname} ne "" ) {
83     $cvscmd=$cvscms." -d ".$self->{dirname};
84 williamc 1.3 $rv=$self->{dirname};
85     }
86     else {
87     $rv=$self->getfilefrompath($url);
88 williamc 1.1 }
89    
90     #
91     # Check to see we have a server and if so attempt the checkout
92     #
93     if ( ! defined $self->{cvsobject} ) {
94     print "urlhandler error: undefined cvs server for $module\n";
95 williamc 1.3 $rv="";
96 williamc 1.1 }
97     else {
98 williamc 1.5 use Cwd;
99     my $thisdir=cwd();
100     chdir $dir;
101 williamc 1.1 $self->{cvsobject}->invokecvs($cvscmd, $module);
102 williamc 1.5 chdir $thisdir;
103 williamc 1.1 }
104 williamc 1.3 return $rv;
105 williamc 1.1 }