Subversion Repositories DevTools

Rev

Rev 1295 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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 viewcvs.cgi.
9
 
10
package Codestriker::Repository::ViewCvs;
11
 
12
use strict;
13
 
14
use LWP::UserAgent;
15
 
16
# Constructor, which takes as a parameter the URL to the viewcvs repository,
17
# and the CVSROOT.
18
sub new ($$) {
19
    my ($type, $viewcvs_url, $cvsroot) = @_;
20
 
21
    my $self = {};
22
    $self->{viewcvs_url} = $viewcvs_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->{viewcvs_url} .
35
	"/${filename}?rev=${revision}&content-type=text/plain";
36
    my $response = $ua->get($request);
37
    my $content = Codestriker::decode_topic_text($response->content);
38
 
39
    # Store the content lines.
40
    my @content_lines = split /\n/, $content;
41
    for (my $i = 0; $i <= $#content_lines; $i++) {
42
	$$content_array_ref[$i+1] = $content_lines[$i];
43
    }
44
}
45
 
46
# Retrieve the "root" of this repository.
47
sub getRoot ($) {
48
    my ($self) = @_;
49
    return $self->{cvsroot};
50
}
51
 
52
# Return a URL which views the specified file.
53
sub getViewUrl ($$) {
54
    my ($self, $filename) = @_;
55
 
56
    return $self->{viewcvs_url} . "/" . $filename;
57
}
58
 
59
# Return a string representation of this repository.
60
sub toString ($) {
61
    my ($self) = @_;
62
    return $self->{viewcvs_url} . " " . $self->{cvsroot};
63
}
64
 
65
# The getDiff operation is not supported.
66
sub getDiff ($$$$$) {
67
    my ($self, $start_tag, $end_tag, $module_name, $fh, $error_fh) = @_;
68
 
69
    return $Codestriker::UNSUPPORTED_OPERATION;
70
}
71
 
72
1;