ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/URL_cvs.pm
Revision: 1.12.2.2
Committed: Thu Aug 10 17:00:58 2000 UTC (24 years, 9 months ago) by williamc
Content type: text/plain
Branch: HPWbranch
CVS Tags: V0_14_0
Changes since 1.12.2.1: +9 -3 lines
Log Message:
Fixes for extra long locations

File Contents

# User Rev Content
1 williamc 1.1 #
2     # standard url interface for cvs
3     #
4 williamc 1.12 # cvs urls
5     #
6     # cvs://server_name:/repository_location?passkey=xxx&auth=xxx&user=xxx
7     # &module=co_files
8     #
9 williamc 1.9 # Interface
10 williamc 1.1 #-------------
11     # new() :
12 williamc 1.5 # get(url,$dirname) :
13 williamc 1.1
14 williamc 1.4 package URL::URL_cvs;
15 williamc 1.1 require 5.001;
16     use Utilities::CVSmodule;
17 williamc 1.12 use URL::URL_base;
18 williamc 1.1 use Carp;
19 williamc 1.12 @ISA = qw(URL::URL_base);
20 williamc 1.1
21     sub init {
22     my $self=shift;
23     $self->{cvsco}="co";
24     }
25    
26     sub setbase {
27     my $self=shift;
28 williamc 1.7 my $base=shift;
29 williamc 1.1 my $varhash=shift;
30    
31     my $auth=$$varhash{'auth'};
32    
33     # a new cvs object
34     $self->{cvsobject}=CVSmodule->new();
35     $self->{cvsobject}->set_base($base);
36     $self->{cvsobject}->set_auth($auth);
37     if ( exists $$varhash{'user'} ) {
38     $self->{cvsobject}->set_user($$varhash{'user'});
39     }
40     if ( exists $$varhash{'passkey'} ) {
41     $self->{cvsobject}->set_passkey($$varhash{'passkey'});
42     }
43     if ( exists $$varhash{'method'} ) {
44     $self->{cvsco}=$$varhash{'method'};
45     }
46     # Alternative dir name to co to
47     if ( exists $$varhash{'name'} ) {
48     $self->{dirname}=$$varhash{'name'};
49     }
50     }
51    
52     sub get {
53     my $self=shift;
54     my $url=shift;
55 williamc 1.6 my $location=shift;
56 williamc 1.1
57 williamc 1.6 use File::Basename;
58 williamc 1.9 my ($dir,$dirname)=($location=~/(.*)\/(.*)/);
59 williamc 1.7 #my $dir=dirname($location);
60 williamc 1.8 use Utilities::AddDir;
61 williamc 1.12.2.2 if ( $dir ne $location ) {
62     AddDir::adddir($dir);
63     }
64 williamc 1.6
65     my @cvscmd=($self->{cvsco});
66 williamc 1.12 $self->setbase($url->servername().":/".$url->path(),$url->vars());
67 williamc 1.7 my $version=$url->param('version');
68 williamc 1.6 my $rv="";
69 williamc 1.12 my $module;
70     ($module=$url->param('module'))=~s/\/$//;
71     my $filename="";
72     if ( $module=~/\/.?/ ) {
73     ($filename=$module)=~s/.*\///;
74     }
75 williamc 1.1
76 williamc 1.9 push @cvscmd, ("-d", "$dirname");
77 williamc 1.7 if ( $version && ($version ne "") ) {
78 williamc 1.6 push @cvscmd, ("-r", "$version");
79 williamc 1.1 }
80     #
81     # Check to see we have a server and if so attempt the checkout
82     #
83     if ( ! defined $self->{cvsobject} ) {
84 williamc 1.12 $self->error("undefined cvs server for $module");
85 williamc 1.1 }
86     else {
87 williamc 1.12 if ( ! defined $module ) {
88     $self->error("undefined module to checkout");
89     }
90     else {
91 williamc 1.5 use Cwd;
92     my $thisdir=cwd();
93 williamc 1.9 chdir $dir or die "unable to enter directory $dir\n";
94 williamc 1.12 # print "Entering $dir to @cvscmd ".$module."\n";
95     $self->{cvsobject}->invokecvs(@cvscmd, $module);
96 williamc 1.5 chdir $thisdir;
97 williamc 1.9 if ( -e $location."/".$filename ) {
98 williamc 1.12 $rv=$location."/".$filename;
99     $rv=~s/\/$//;
100 williamc 1.12.2.2 }
101     elsif ( -d $location."/CVS" ) {
102     $rv=$location;
103     $rv=~s/\/$//;
104     }
105 williamc 1.9 else {
106 williamc 1.12 $self->error("Download failed for ".$url->url());
107 williamc 1.12.2.2 print $location."/".$filename." does not exist\n";
108 williamc 1.9 }
109 williamc 1.12 }
110 williamc 1.9 }
111 williamc 1.3 return $rv;
112 williamc 1.12 }
113    
114     sub error {
115     my $self=shift;
116     my $string=shift;
117    
118     print "cvs handler error: ".$string."\n";
119 williamc 1.1 }