ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/URL_cvs.pm
Revision: 1.1
Committed: Mon Aug 23 13:01:55 1999 UTC (25 years, 8 months ago) by williamc
Content type: text/plain
Branch: MAIN
Log Message:
Basic Testing Complete

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     # get(url, destination) :
10    
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     my $dirname=shift;
67    
68     my $cvscmd;
69     my $module="";
70     my $version="";
71    
72     # Split up our url into its components
73     if ( $url=~/\?/ ) {
74     ($module, $version)= split /\?/, $url;
75     }
76     else {
77     $module=$url;
78     }
79    
80     if ( $version ne "" ) {
81     $cvscmd=$self->{cvsco}." -r $version";
82     }
83     else {
84     $cvscmd=$self->{cvsco};
85     }
86     if ( $self->{dirname} ne "" ) {
87     $cvscmd=$cvscms." -d ".$self->{dirname};
88     }
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     return 1;
96     }
97     else {
98     chdir $dirname or carp "Unable to Enter Directory $dirname $!\n";
99     $self->{cvsobject}->invokecvs($cvscmd, $module);
100     }
101     }