ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/URL_cvs.pm
Revision: 1.6
Committed: Thu Nov 4 13:47:23 1999 UTC (25 years, 6 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.5: +19 -18 lines
Log Message:
Updates to interface change and baseurl

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.6 # baseurl() :
11 williamc 1.1
12 williamc 1.4 package URL::URL_cvs;
13 williamc 1.1 require 5.001;
14     use Utilities::CVSmodule;
15 williamc 1.4 use URL::URL_base;
16 williamc 1.1 use Carp;
17 williamc 1.4 @ISA = qw(URL::URL_base);
18 williamc 1.1
19     sub init {
20     my $self=shift;
21     $self->{cvsco}="co";
22 williamc 1.3 $self->{dirname}="";
23 williamc 1.1 }
24    
25     sub setbase {
26     my $self=shift;
27     my $varhash=shift;
28    
29     my $base=$$varhash{'base'};
30     my $auth=$$varhash{'auth'};
31    
32     # a new cvs object
33     $self->{cvsobject}=CVSmodule->new();
34     $self->{cvsobject}->set_base($base);
35     $self->{cvsobject}->set_auth($auth);
36     if ( exists $$varhash{'user'} ) {
37     $self->{cvsobject}->set_user($$varhash{'user'});
38     }
39     if ( exists $$varhash{'passkey'} ) {
40     $self->{cvsobject}->set_passkey($$varhash{'passkey'});
41     }
42     if ( exists $$varhash{'method'} ) {
43     $self->{cvsco}=$$varhash{'method'};
44     }
45     # Alternative dir name to co to
46     if ( exists $$varhash{'name'} ) {
47     $self->{dirname}=$$varhash{'name'};
48     }
49     }
50    
51     sub unsetbase {
52     my $self=shift;
53     delete $self->{cvsobject};
54     }
55    
56     #
57 williamc 1.6 # url module?version
58 williamc 1.1 #
59     sub get {
60     my $self=shift;
61     my $url=shift;
62 williamc 1.6 my $location=shift;
63 williamc 1.1
64 williamc 1.6 use File::Basename;
65     my $dirname=$self->getfilefrompath($location);
66     my $dir=dirname($location);
67    
68     my @cvscmd=($self->{cvsco});
69 williamc 1.1 my $module="";
70     my $version="";
71 williamc 1.6 my $rv="";
72 williamc 1.1
73     # Split up our url into its components
74     if ( $url=~/\?/ ) {
75 williamc 1.6 ($module,$version)= split /\?/, $url;
76 williamc 1.1 }
77     else {
78     $module=$url;
79     }
80    
81     if ( $version ne "" ) {
82 williamc 1.6 push @cvscmd, ("-r", "$version");
83 williamc 1.1 }
84 williamc 1.6 push @cvscmd, ("-d", $dirname);
85 williamc 1.1
86     #
87     # Check to see we have a server and if so attempt the checkout
88     #
89     if ( ! defined $self->{cvsobject} ) {
90     print "urlhandler error: undefined cvs server for $module\n";
91     }
92     else {
93 williamc 1.5 use Cwd;
94     my $thisdir=cwd();
95     chdir $dir;
96 williamc 1.6 $self->{cvsobject}->invokecvs(@cvscmd, $module);
97 williamc 1.5 chdir $thisdir;
98 williamc 1.6 if ( -e $location ) { $rv=$location } ;
99 williamc 1.1 }
100 williamc 1.3 return $rv;
101 williamc 1.6 }
102    
103     sub baseurl {
104     my $self=shift;
105     $rep=$self->{cvsobject}->repository();
106 williamc 1.1 }