| 1 | # | ||||||||||||||||||||
| 2 | # Copyright (c) 2003,2004,2005 Alexander Taler (dissent@0--0.org) | ||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | # All rights reserved. This program is free software; you can redistribute it | ||||||||||||||||||||
| 5 | # and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||
| 6 | # | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | package VCS::LibCVS::Datum::Root; | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 1 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | VCS::LibCVS::Datum::Root - A CVS datum for a CVS Root specification | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | $root = VCS::LibCVS::Datum::Root->new(':pserver:user@cvs.cvshome.org:/cvs'); | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | =head1 DESCRIPTION | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | A CVS Root specification. | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | [ : <protocol> : [ <username> @ <hostname> [ : <port> ] ] ] <rootdir> | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | If only the rootdir is specified, protocol will be reported as "local". | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | =head1 SUPERCLASS | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | VCS::LibCVS::Datum | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | =cut | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | ############################################################################### | ||||||||||||||||||||
| 36 | # Class constants | ||||||||||||||||||||
| 37 | ############################################################################### | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 1 | ▶ | use constant REVISION => '$Header: /cvsroot/libcvs-perl/libcvs-perl/VCS/LibCVS/Datum/Root.pm,v 1.19 2005/10/10 12:52:12 dissent Exp $ '; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 1 | ▶ | use vars ('@ISA'); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 42 | 1 | @ISA = ("VCS::LibCVS::Datum"); | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | ############################################################################### | ||||||||||||||||||||
| 45 | # Class variables | ||||||||||||||||||||
| 46 | ############################################################################### | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | ############################################################################### | ||||||||||||||||||||
| 49 | # Private variables | ||||||||||||||||||||
| 50 | ############################################################################### | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | # $self->{Protocol} "local", "ext", "pserver", . . . | ||||||||||||||||||||
| 53 | # $self->{UserName} for ext and pserver | ||||||||||||||||||||
| 54 | # $self->{HostName} for ext and pserver | ||||||||||||||||||||
| 55 | # $self->{Port} for ext and pserver | ||||||||||||||||||||
| 56 | # $self->{RootDir} | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | ############################################################################### | ||||||||||||||||||||
| 59 | # Class routines | ||||||||||||||||||||
| 60 | ############################################################################### | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||
| 63 | 0 | my $class = shift; | |||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 0 | my $that = $class->SUPER::new(@_); | |||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | # If it starts with a /, it's a local directory name. | ||||||||||||||||||||
| 68 | 0 | ▶ | if ($that->{Root} =~ m/^\//) { | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 69 | 0 | $that->{Protocol} = "local"; | |||||||||||||||||||
| 70 | 0 | $that->{RootDir} = $that->{Root}; | |||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | # If it starts with a :, then the protocol has been specified, and the | ||||||||||||||||||||
| 73 | # hostname is optional. | ||||||||||||||||||||
| 74 | } elsif ($that->{Root} =~ /^:[^\/]+\//) { | ||||||||||||||||||||
| 75 | 0 | $that->{Root} =~ /^:([^:]*):?(([^\@]*)\@)?([^:\/]*)(:([0-9]*))?(\/.*)$/; | |||||||||||||||||||
| 76 | 0 | $that->{Protocol} = $1; | |||||||||||||||||||
| 77 | 0 | ▶ | $that->{UserName} = $3 || getlogin(); | ||||||||||||||||||
|
Condition0%0/3
$3 || getlogin
MC/DC0%0/2
$3 || getlogin
$3
getlogin
Truth table0%0/3
A || B
A= $3B= getlogin
| |||||||||||||||||||||
| 78 | 0 | $that->{HostName} = $4; | |||||||||||||||||||
| 79 | 0 | $that->{Port} = $6; | |||||||||||||||||||
| 80 | 0 | $that->{RootDir} = $7; | |||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | # Otherwise it's remote without the protocol specified, starting with the | ||||||||||||||||||||
| 83 | # hostname. This allows for the perverse case, where there are no :'s, such | ||||||||||||||||||||
| 84 | # as fire/var/cvs which is on host fire, in directory /var/cvs. | ||||||||||||||||||||
| 85 | } elsif ($that->{Root} =~ /^[^\/]+\//) { | ||||||||||||||||||||
| 86 | 0 | $that->{Root} =~ /^(([^\@]*)\@)?([^:\/]*)(:([0-9]*))?(\/.*)$/; | |||||||||||||||||||
| 87 | 0 | $that->{Protocol} = "ext"; | |||||||||||||||||||
| 88 | 0 | ▶ | $that->{UserName} = $2 || getlogin(); | ||||||||||||||||||
|
Condition0%0/3
$2 || getlogin
MC/DC0%0/2
$2 || getlogin
$2
getlogin
Truth table0%0/3
A || B
A= $2B= getlogin
| |||||||||||||||||||||
| 89 | 0 | $that->{HostName} = $3; | |||||||||||||||||||
| 90 | 0 | $that->{Port} = $5; | |||||||||||||||||||
| 91 | 0 | $that->{RootDir} = $6; | |||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | } else { | ||||||||||||||||||||
| 94 | 0 | confess "Couldn't parse Root: $that->{Root}"; | |||||||||||||||||||
| 95 | } | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | 0 | return $that; | |||||||||||||||||||
| 98 | } | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | ############################################################################### | ||||||||||||||||||||
| 101 | # Instance routines | ||||||||||||||||||||
| 102 | ############################################################################### | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | =head1 INSTANCE ROUTINES | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | =head2 B<get_dir()> | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | $dir = $root->get_dir() | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | =over 4 | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | =item return type: scalar string | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | The name of the root directory. | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | =back | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | =cut | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | 0 | ▶ | sub get_dir { | ||||||||||||||||||
|
Subroutine
get_dir: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 121 | 0 | my $self = shift; | |||||||||||||||||||
| 122 | 0 | return $self->{RootDir}; | |||||||||||||||||||
| 123 | } | ||||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | ############################################################################### | ||||||||||||||||||||
| 127 | # Private routines | ||||||||||||||||||||
| 128 | ############################################################################### | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | 0 | ▶ | sub _data_names { return ("Root"); } | ||||||||||||||||||
|
Subroutine
_data_names: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | # Should have accessors for each chunk of data. | ||||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | =head1 SEE ALSO | ||||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | VCS::LibCVS::Datum | ||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | =cut | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | 1 | 1; | |||||||||||||||||||