« blib/lib/VCS/LibCVS/Client/Request/Argument.pm
↑ Summary
blib/lib/VCS/LibCVS/WorkingUnmanagedFile.pm »
| 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::Repository; | ||||||||||||||||||||||||||||
| 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::Repository - A CVS Repository. | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | Represents a CVS Repository. | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =cut | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | ############################################################################### | ||||||||||||||||||||||||||||
| 26 | # Class constants | ||||||||||||||||||||||||||||
| 27 | ############################################################################### | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 1 | ▶ | use constant REVISION => '$Header: /cvsroot/libcvs-perl/libcvs-perl/VCS/LibCVS/Repository.pm,v 1.19 2005/10/10 12:52:11 dissent Exp $ '; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | ############################################################################### | ||||||||||||||||||||||||||||
| 32 | # Class variables | ||||||||||||||||||||||||||||
| 33 | ############################################################################### | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # Cache Repository objects. Any attempt to create a new repository object with | ||||||||||||||||||||||||||||
| 36 | # the same Root will return one from the cache. | ||||||||||||||||||||||||||||
| 37 | 1 | ▶ | use vars ('%Repository_Cache'); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | ############################################################################### | ||||||||||||||||||||||||||||
| 40 | # Private variables | ||||||||||||||||||||||||||||
| 41 | ############################################################################### | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | # $self->{Root} object of type VCS::LibCVS::Datum::Root | ||||||||||||||||||||||||||||
| 44 | # $self->{Client} already connected VCS::LibCVS::Client | ||||||||||||||||||||||||||||
| 45 | # $self->{IgnoreChecker} object of type VCS::LibCVS::IgnoreChecker | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | # $self->{RepositoryFileOrDirectoryCache} hashref containing | ||||||||||||||||||||||||||||
| 48 | # RepositoryFileOrDirectory instances | ||||||||||||||||||||||||||||
| 49 | # in this repo, keys are filenames | ||||||||||||||||||||||||||||
| 50 | # relative to the root | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | ########## | ||||||||||||||||||||||||||||
| 53 | # $self->{FileRevisionContentsCache} hashref containing file revision contents | ||||||||||||||||||||||||||||
| 54 | # | ||||||||||||||||||||||||||||
| 55 | # keys are filenames (relative to the root) and revisions, like so: | ||||||||||||||||||||||||||||
| 56 | # "CVSROOT/modules:1.2" | ||||||||||||||||||||||||||||
| 57 | # | ||||||||||||||||||||||||||||
| 58 | # This cache is populated by objects of type FileRevision. This cache is | ||||||||||||||||||||||||||||
| 59 | # necessary because of the way CVS works; it won't return the contents of the | ||||||||||||||||||||||||||||
| 60 | # same revision twice in a row over a single client connection. | ||||||||||||||||||||||||||||
| 61 | # | ||||||||||||||||||||||||||||
| 62 | # It can grow large if FileRevision is used often across a single connection. | ||||||||||||||||||||||||||||
| 63 | # For this reason it makes sense to clean it up as soon as possible once the | ||||||||||||||||||||||||||||
| 64 | # connection comes down. That's why the cache is here and not in the | ||||||||||||||||||||||||||||
| 65 | # FileContents class itself. Furthermore, if another class wanted direct | ||||||||||||||||||||||||||||
| 66 | # access to the contents of a revision, it would need access to this Cache | ||||||||||||||||||||||||||||
| 67 | # also. | ||||||||||||||||||||||||||||
| 68 | ########## | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | ############################################################################### | ||||||||||||||||||||||||||||
| 71 | # Class routines | ||||||||||||||||||||||||||||
| 72 | ############################################################################### | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =head1 CLASS ROUTINES | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =head2 B<new()> | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | $repo = VCS::LibCVS::Repository->new($root) | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =over 4 | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =item return type: VCS::LibCVS::Repository | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =item argument 1 type: . . . | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | The root of the repository, like this: :pserver:user@cvs.cvshome.org:/cvs | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =over 2 | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =item E<32>E<32>option 1: scalar string | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =item E<32>E<32>option 2: VCS::LibCVS::Datum::Root | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =back | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =back | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | Creates a new Repository object with the specified root. | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | There is no check that the specified repository actually exists or is | ||||||||||||||||||||||||||||
| 101 | accessible. | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =cut | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 106 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 107 | 0 | my $root = shift; | |||||||||||||||||||||||||||
| 108 | 0 | my $root_string; | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if (!ref($root)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 0 | $root_string = $root; | |||||||||||||||||||||||||||
| 112 | 0 | $root = VCS::LibCVS::Datum::Root->new($root); | |||||||||||||||||||||||||||
| 113 | } else { | ||||||||||||||||||||||||||||
| 114 | 0 | $root_string = $root->as_string(); | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if ($VCS::LibCVS::Cache_Repository && $Repository_Cache{$root_string}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$VCS::LibCVS::Cache_Repository and $VCS::LibCVS::Repository::Repository_Cache{$root_string}
MC/DC0%0/2
$VCS::LibCVS::Cache_Repository and $VCS::LibCVS::Repository::Repository_Cache{$root_string}
$VCS::LibCVS::Cache_Repository
$VCS::LibCVS::Repository::Repository_Cache{$root_string}
Truth table0%0/3
A and B
A= $VCS::LibCVS::Cache_RepositoryB= $VCS::LibCVS::Repository::Repository_Cache{$root_string}
| |||||||||||||||||||||||||||||
| 118 | 0 | return ($Repository_Cache{$root_string}) | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | my $that = bless {}, $class; | |||||||||||||||||||||||||||
| 122 | 0 | $that->{Root} = $root; | |||||||||||||||||||||||||||
| 123 | 0 | $that->{FileRevisionContentsCache} = {}; | |||||||||||||||||||||||||||
| 124 | 0 | $that->{RepositoryFileOrDirectoryCache} = {}; | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | $Repository_Cache{$root_string} = $that if $VCS::LibCVS::Cache_Repository; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 0 | return $that; | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | ############################################################################### | ||||||||||||||||||||||||||||
| 132 | # Instance routines | ||||||||||||||||||||||||||||
| 133 | ############################################################################### | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | =head1 INSTANCE ROUTINES | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | =head2 B<get_root()> | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | $root = $repo->get_root() | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =over 4 | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | =item return type: VCS::LibCVS::Datum::Root | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | =back | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | Returns the root of this repository | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | =cut | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub get_root { | ||||||||||||||||||||||||||
|
Subroutine
get_root: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 152 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 153 | 0 | return $self->{Root}; | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | =head2 B<get_version()> | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | $CVS_version = $repo->get_version() | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | =over 4 | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | =item return type: scalar string | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | =back | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | Returns the version of CVS running at this repository | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | =cut | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 0 | ▶ | sub get_version { | ||||||||||||||||||||||||||
|
Subroutine
get_version: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 171 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 0 | my $client = $self->_new_client(); | |||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | # If the version request is not supported, then it's pre 1.11 | ||||||||||||||||||||||||||||
| 176 | 0 | ▶ | return "pre 1.11" unless ($client->valid_requests()->{version}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | # Call the version request and return its result | ||||||||||||||||||||||||||||
| 179 | 0 | my $request = VCS::LibCVS::Client::Request::version->new(); | |||||||||||||||||||||||||||
| 180 | 0 | my @responses = $client->submit_request($request); | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | # Throw an exception in case of error | ||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if (($responses[-1]->isa("VCS::LibCVS::Client::Response::error"))) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | 0 | my $errors; | |||||||||||||||||||||||||||
| 185 | 0 | ▶ | foreach my $resp (@responses) { $errors .= ($resp->get_errors() || ""); }; | ||||||||||||||||||||||||||
|
Condition0%0/2
$resp->get_errors || ''
MC/DC0%0/1
$resp->get_errors || ''
$resp->get_errors
Truth table0%0/2
A
A= $resp->get_errors
| |||||||||||||||||||||||||||||
| 186 | 0 | confess "Request failed: \"$errors\""; | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | # The first response should be of type M, with it's value the version | ||||||||||||||||||||||||||||
| 190 | 0 | return $responses[0]->get_message(); | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | =head2 B<get_ignoreChecker()> | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | $ignoreChecker = $repo->get_ignoreChecker() | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | =over 4 | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | =item return type: VCS::LibCVS::IgnoreChecker | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | =back | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | Returns an IgnoreChecker for this repository | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | =cut | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 0 | ▶ | sub get_ignoreChecker { | ||||||||||||||||||||||||||
|
Subroutine
get_ignoreChecker: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 208 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 0 | ▶ | if ( ! $self->{IgnoreChecker} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | 0 | $self->{IgnoreChecker} = VCS::LibCVS::IgnoreChecker->new($self); | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | 0 | return $self->{IgnoreChecker}; | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | =head2 B<equals()> | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | if ($repo1->equals($repo2)) { | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | =over 4 | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | =item return type: boolean | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | =item argument 1 type: VCS::LibCVS::Repository | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | =back | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | Returns true if this and the argument represent the same the repository. | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | =cut | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 0 | ▶ | sub equals { | ||||||||||||||||||||||||||
|
Subroutine
equals: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 233 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 234 | 0 | my $other = shift; | |||||||||||||||||||||||||||
| 235 | 0 | return $self->{Root}->equals($other->{Root}); | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | ############################################################################### | ||||||||||||||||||||||||||||
| 239 | # Private routines | ||||||||||||||||||||||||||||
| 240 | ############################################################################### | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | # VCS::LibCVS::Client | ||||||||||||||||||||||||||||
| 243 | # | ||||||||||||||||||||||||||||
| 244 | # Returns a client connected to this repository. | ||||||||||||||||||||||||||||
| 245 | # See Client.pm for details of why a repository directory name is passed. | ||||||||||||||||||||||||||||
| 246 | # Used in Command.pm | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | ▶ | sub _get_client { | ||||||||||||||||||||||||||
|
Subroutine
_get_client: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 249 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 250 | 0 | my $any_repo_dir = shift; | |||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if ( ! $self->{Client} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 0 | $self->{Client} = $self->_new_client($any_repo_dir); | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 0 | return $self->{Client}; | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | # create a new client, connected to the repo. | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 0 | ▶ | sub _new_client { | ||||||||||||||||||||||||||
|
Subroutine
_new_client: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 262 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 263 | 0 | my $any_repo_dir = shift; | |||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 0 | my $conn = VCS::LibCVS::Client::Connection->new($self->{Root}); | |||||||||||||||||||||||||||
| 266 | 0 | my $client = VCS::LibCVS::Client->new($conn, $self->{Root}->{RootDir}); | |||||||||||||||||||||||||||
| 267 | # Turn off two possible responses. This will put all file transmissions | ||||||||||||||||||||||||||||
| 268 | # through the Updated responses, which is fine since this client is smarter | ||||||||||||||||||||||||||||
| 269 | # than the regular cvs client. | ||||||||||||||||||||||||||||
| 270 | 0 | $client->valid_responses()->{'Update-existing'} = 0; | |||||||||||||||||||||||||||
| 271 | 0 | $client->valid_responses()->{'Created'} = 0; | |||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 0 | $client->testing_dir($any_repo_dir); | |||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 0 | $client->connect(); | |||||||||||||||||||||||||||
| 276 | 0 | return $client; | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | # Clean up the Repository_Cache | ||||||||||||||||||||||||||||
| 280 | 1 | ▶ | sub END { | ||||||||||||||||||||||||||
|
Subroutine
END: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||
| 281 | 1 | foreach my $key (keys (%Repository_Cache)) { | |||||||||||||||||||||||||||
| 282 | 0 | delete ($Repository_Cache{$key}); | |||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | VCS::LibCVS | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | =cut | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 1 | 1; | |||||||||||||||||||||||||||