ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/URL_cvs.pm
Revision: 1.13
Committed: Mon Aug 28 08:22:57 2000 UTC (24 years, 8 months ago) by williamc
Content type: text/plain
Branch: MAIN
CVS Tags: V0_19_5, SFATEST, V0_19_4, V0_19_4_pre3, V0_19_4_pre2, V0_19_4_pre1, V0_19_3, V0_19_2, V0_19_1, V0_19_0, V0_18_5, V0_18_4, V_18_3_TEST, VO_18_3, V0_18_2, V0_18_1
Branch point for: V0_19_4_B
Changes since 1.12: +56 -46 lines
Log Message:
Imported from HPWbranch

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.13 use Cwd;
20    
21 williamc 1.12 @ISA = qw(URL::URL_base);
22 williamc 1.1
23     sub init {
24     my $self=shift;
25     $self->{cvsco}="co";
26     }
27    
28     sub setbase {
29     my $self=shift;
30 williamc 1.7 my $base=shift;
31 williamc 1.1 my $varhash=shift;
32    
33     my $auth=$$varhash{'auth'};
34    
35     # a new cvs object
36 williamc 1.13 $self->{cvsobject}=Utilities::CVSmodule->new();
37 williamc 1.1 $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 williamc 1.6 my $location=shift;
58 williamc 1.13 my $rv="";
59 williamc 1.1
60 williamc 1.6 use File::Basename;
61 williamc 1.9 my ($dir,$dirname)=($location=~/(.*)\/(.*)/);
62 williamc 1.12 $self->setbase($url->servername().":/".$url->path(),$url->vars());
63 williamc 1.13 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 williamc 1.12 }
71 williamc 1.13 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 williamc 1.1
86 williamc 1.13 push @cvscmd, ("-d", "$dirname");
87     if ( $version && ($version ne "") ) {
88 williamc 1.6 push @cvscmd, ("-r", "$version");
89 williamc 1.13 }
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 williamc 1.12 $rv=$location."/".$filename;
108     $rv=~s/\/$//;
109 williamc 1.13 }
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 williamc 1.12 }
121 williamc 1.9 }
122 williamc 1.3 return $rv;
123 williamc 1.1 }