| 1293 |
dpurdie |
1 |
###############################################################################
|
|
|
2 |
# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
|
|
|
3 |
# sits@users.sourceforge.net
|
|
|
4 |
#
|
|
|
5 |
# This program is free software; you can redistribute it and modify it under
|
|
|
6 |
# the terms of the GPL.
|
|
|
7 |
|
|
|
8 |
# Repository class which retrieves data using cvsweb.cgi.
|
|
|
9 |
|
|
|
10 |
package Codestriker::Repository::CvsWeb;
|
|
|
11 |
|
|
|
12 |
use strict;
|
|
|
13 |
|
|
|
14 |
use LWP::UserAgent;
|
|
|
15 |
|
|
|
16 |
# Constructor, which takes as a parameter the URL to the cvsweb repository,
|
|
|
17 |
# and the CVSROOT.
|
|
|
18 |
sub new ($$) {
|
|
|
19 |
my ($type, $cvsweb_url, $cvsroot) = @_;
|
|
|
20 |
|
|
|
21 |
my $self = {};
|
|
|
22 |
$self->{cvsweb_url} = $cvsweb_url;
|
|
|
23 |
$self->{cvsroot} = $cvsroot;
|
|
|
24 |
bless $self, $type;
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
# Retrieve the data corresponding to $filename and $revision. Store each line
|
|
|
28 |
# into $content_array_ref.
|
|
|
29 |
sub retrieve ($$$\$) {
|
|
|
30 |
my ($self, $filename, $revision, $content_array_ref) = @_;
|
|
|
31 |
|
|
|
32 |
# Retrieve the data by doing an HTPP GET to the remote viewcvs server.
|
|
|
33 |
my $ua = LWP::UserAgent->new;
|
|
|
34 |
my $request = $self->{cvsweb_url} . "/~checkout~" .
|
|
|
35 |
"/${filename}?rev=${revision}&content-type=text/plain";
|
|
|
36 |
my $response = $ua->get($request);
|
|
|
37 |
my $content = Codestriker::decode_topic_text($response->content);
|
|
|
38 |
# Store the content lines.
|
|
|
39 |
my @content_lines = split /\n/, $content;
|
|
|
40 |
for (my $i = 0; $i <= $#content_lines; $i++) {
|
|
|
41 |
$$content_array_ref[$i+1] = $content_lines[$i];
|
|
|
42 |
}
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
# Retrieve the "root" of this repository.
|
|
|
46 |
sub getRoot ($) {
|
|
|
47 |
my ($self) = @_;
|
|
|
48 |
return $self->{cvsroot};
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
# Return a URL which views the specified file.
|
|
|
52 |
sub getViewUrl ($$) {
|
|
|
53 |
my ($self, $filename) = @_;
|
|
|
54 |
|
|
|
55 |
return $self->{cvsweb_url} . "/" . $filename;
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
# Return a string representation of this repository.
|
|
|
59 |
sub toString ($) {
|
|
|
60 |
my ($self) = @_;
|
|
|
61 |
return $self->{cvsweb_url} . " " . $self->{cvsroot};
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
# The getDiff operation is not supported.
|
|
|
65 |
sub getDiff ($$$$$) {
|
|
|
66 |
my ($self, $start_tag, $end_tag, $module_name, $fh, $error_fh) = @_;
|
|
|
67 |
|
|
|
68 |
return $Codestriker::UNSUPPORTED_OPERATION;
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
1;
|