ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/URL_cvs.pm
Revision: 1.12.2.6
Committed: Mon Aug 28 07:03:29 2000 UTC (24 years, 8 months ago) by williamc
Content type: text/plain
Branch: HPWbranch
CVS Tags: BuildSystemProto1, V0_18_0, V0_18_0model, V0_17_1, V0_18_0alpha, V0_17_0, V0_16_4, V0_16_3, V0_16_2, V0_16_1, V0_16_0, V0_15_1, V0_15_0, V0_15_0beta
Branch point for: V0_17branch, V0_16branch, V0_15branch
Changes since 1.12.2.5: +3 -9 lines
Log Message:
Update error handling URL

File Contents

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