summaryrefslogtreecommitdiffstats
path: root/Bugzilla/PatchReader/CVSClient.pm
blob: 2f76fc18d17827412eb577abe4e142ff0dc8a619 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.

package Bugzilla::PatchReader::CVSClient;

use strict;

sub parse_cvsroot {
    my $cvsroot = $_[0];
    # Format: :method:[user[:password]@]server[:[port]]/path
    if ($cvsroot =~ /^:([^:]*):(.*?)(\/.*)$/) {
        my %retval;
        $retval{protocol} = $1;
        $retval{rootdir} = $3;
        my $remote = $2;
        if ($remote =~ /^(([^\@:]*)(:([^\@]*))?\@)?([^:]*)(:(.*))?$/) {
            $retval{user} = $2;
            $retval{password} = $4;
            $retval{server} = $5;
            $retval{port} = $7;
            return %retval;
        }
    }

    return (
        rootdir => $cvsroot
    );
}

sub cvs_co {
    my ($cvsroot, @files) = @_;
    my $cvs = $::cvsbin || "cvs";
    return system($cvs, "-Q", "-d$cvsroot", "co", @files);
}

sub cvs_co_rev {
    my ($cvsroot, $rev, @files) = @_;
    my $cvs = $::cvsbin || "cvs";
    return system($cvs, "-Q", "-d$cvsroot", "co", "-r$rev", @files);
}

1