blib/lib/VCS/LibCVS/Client.pm

filter: Statementstmt 33.7% 62 / 184 Branchbran 0.0% 0 / 36 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 64.5% 20 / 31 Podpod 100% 8 / 8 totaltotal 32.4% 90 / 277 CC 28 SCAR 33.6
CC
28
Cov
27%
_test_support_multiple_commands
110.0
new
30.0
submit_request
30.0
CRAP 28.8
« blib/lib/VCS/LibCVS/WorkingFile.pm ↑ Summary blib/lib/VCS/LibCVS/RepositoryFileOrDirectory.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::Client;
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::Client - an implementation of the CVS client protocol
16  
17 =head1 SYNOPSIS
18  
19 use VCS::LibCVS::Client;
20 use VCS::LibCVS::Datum;
21  
22 my $conn = VCS::LibCVS::Client::Connection::Local->new();
23 my $client = VCS::LibCVS::Client->new($conn, "/cvs");
24 $client->connect();
25 my $request
26 = VCS::LibCVS::Client::Request::Directory->new(["dir","/cvs/dir"]));
27 my @responses = $client->submit_request($request);
28  
29 =head1 DESCRIPTION
30  
31 VCS::LibCVS provides native Perl access to CVS. This is the CVS client
32 protocol component of VCS::LibCVS. Do not use this directly, use
33 VCS::LibCVS instead. However, if you really insist, this
34 implementation does work stand-alone.
35  
36 This documentation assumes you are already familiar with the cvsclient
37 protocol which is documented in the cvsclient info node.
38  
39 This module uses exceptions to report errors, except where otherwise noted.
40  
41 This implementation is a very thin layer over the CVS client protocol, although
42 in some places it does a little more, including the following:
43  
44 =over 4
45  
46 =item Initial negotiation
47  
48 When you call connect on the Client, it sends some required requests to the
49 server, and receives some responses from the server. See the documentation of
50 that routine for more details.
51  
52 =item Argumentx
53  
54 There is no Argumentx request, instead Client::Request::Argument handles
55 strings with embedded newlines and issues the Argumentx request itself.
56  
57 =back
58  
59 Throughout these docs, all classnames are relative to VCS::LibCVS::,
60 unless they start with ::.
61  
62 =head1 CLASSES
63  
64 This is a summary of the classes in this implementation. For more details on
65 each of the classes, please see the corresponding docs.
66  
67 =head2 Client
68  
69 This is the main class of the implementation, its instances represent the
70 client end of the CVS client protocol. In order to construct a Client, an
71 instance of Client::Connection must be provided. After construction, a
72 connect() must be called to connect the Client to the server. After a
73 connection has been established, Client::Request's may be submitted to it, and
74 Client::Response's will be received from it.
75  
76 =head2 Client::Connection
77  
78 Instances of this class represent a connection to a particular CVS server.
79 There are several possible types of connection, each with its own subclass,
80 such as Client::Connection::Local. A Client::Connection can be ignored once it
81 has been used to construct a Client and it should not be used to create more
82 than one Client. Note that a CVS server, and thus a Client::Connection, can
83 provide access to more than one CVS repository, for example, there could be
84 repositories at /home/cvs and /home/user1/repository.
85  
86 =head2 Client::Request
87  
88 Instances of this class represent protocol requests which are to be sent to the
89 server. It has subclasses, such as Client::Request::Directory, for each type
90 of protocol request. Each subclass takes specific types of arguments, which
91 are provided in the constructor, either with Datum instances of the appropriate
92 type, or with data that could be used to construct those Datum instances. The
93 routine Client->submit_request() is used to send Client::Request's to the
94 server.
95  
96 =head2 Client::Response
97  
98 Instances of this class represent protocol responses which have been received
99 from the server. It has subclasses, such as Client::Response::Merged for each
100 type of protocol response. The arguments of the response are accessed as
101 instances of subclasses of Datum. Client::Response's are returned by the
102 Client->submit_request() routine.
103  
104 =head1 VCS::LibCVS::Client
105  
106 The rest of this documentation is for the VCS::LibCVS::Client class itself.
107  
108 =cut
109  
110 ###############################################################################
111 # Class constants
112 ###############################################################################
113  
114 1 ▶use constant REVISION => '$Header: /cvsroot/libcvs-perl/libcvs-perl/VCS/LibCVS/Client.pm,v 1.34 2005/10/10 12:52:11 dissent Exp $ ';
Subroutine BEGIN: called CC=1 SCAR=0.0
115  
116 # The default list of valid responses that the client will report
117 1 ▶use constant DEFAULT_VALID_RESPONSES =>
Subroutine BEGIN: called CC=1 SCAR=0.0
118 ("ok", "error", "Valid-requests", "E", "M", "Set-sticky", "Clear-sticky",
119 "Mode", "Mod-time",
120 "Checked-in", "New-entry", "Updated", "Created", "Update-existing",
121 "Merged", "Removed", "Remove-entry",
122 1 );
123  
124 # Turn on and off what to debug
125 1 ▶use vars ('$DebugLevel', '$DebugOut');
Subroutine BEGIN: called CC=1 SCAR=0.0
126 1 $DebugLevel = 0; # Bitmask indicating what debug info to output.
127 # $DebugOut; # Filename for debugging output. Undef means STDERR.
128 1 ▶use constant DEBUG_PROTOCOL => 1; # Print all the protocol data
Subroutine BEGIN: called CC=1 SCAR=0.0
129 1 ▶use constant DEBUG_OPTIONS => 2; # Print out any options
Subroutine BEGIN: called CC=1 SCAR=0.0
130  
131 # The rest of the VCS::LibCVS::Client classes.
132 #
133 # They use the constants defined above.
134  
135 1 ▶use VCS::LibCVS::Client::Connection;
Subroutine BEGIN: called CC=1 SCAR=0.0
136 1 ▶use VCS::LibCVS::Client::Connection::CvsPass;
Subroutine BEGIN: called CC=1 SCAR=0.0
137 1 ▶use VCS::LibCVS::Client::Connection::Local;
Subroutine BEGIN: called CC=1 SCAR=0.0
138 1 ▶use VCS::LibCVS::Client::Connection::Ext;
Subroutine BEGIN: called CC=1 SCAR=0.0
139 1 ▶use VCS::LibCVS::Client::Connection::Pserver;
Subroutine BEGIN: called CC=1 SCAR=0.0
140 1 ▶use VCS::LibCVS::Client::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
141 1 ▶use VCS::LibCVS::Client::Request::Requests;
Subroutine BEGIN: called CC=1 SCAR=0.0
142 1 ▶use VCS::LibCVS::Client::Request::ArgumentUsingRequests;
Subroutine BEGIN: called CC=1 SCAR=0.0
143 1 ▶use VCS::LibCVS::Client::Request::Argument;
Subroutine BEGIN: called CC=1 SCAR=0.0
144 1 ▶use VCS::LibCVS::Client::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
145 1 ▶use VCS::LibCVS::Client::Response::Responses;
Subroutine BEGIN: called CC=1 SCAR=0.0
146 1 ▶use VCS::LibCVS::Client::Response::FileUpdatingResponses;
Subroutine BEGIN: called CC=1 SCAR=0.0
147 1 ▶use VCS::LibCVS::Client::Response::FileUpdateModifyingResponses;
Subroutine BEGIN: called CC=1 SCAR=0.0
148  
149 ###############################################################################
150 # Private variables
151 ###############################################################################
152  
153 # Client is a hash, and uses the following private entries:
154 #
155 # Connected => boolean. True if connected.
156 # Connection => object of type Connection
157 # set in the constructor
158 # Root => string indicating Root directory on server
159 # set in the constructor
160 # ValidResponses => hash ref. Keys for each library supported response, values
161 # of 0 or 1 indicating if the response is valid, as
162 # customized by the user of the library.
163 # ValidRequests => hash ref. Keys for each server supported request, values
164 # of 0 or 1 indicating if the request is valid, as
165 # reported by the server.
166 # SingleCommand => boolean. True means that the server can only support a
167 # single command per connection. In this case, the connection
168 # should be reopened after each command.
169 # TestDir => scalar string. A directory on the server in which a lock file
170 # can be created for connection tests.
171  
172 ###############################################################################
173 # Class routines
174 ###############################################################################
175  
176 =head1 CLASS ROUTINES
177  
178 =head2 B<new()>
179  
180 $client = Client->new($conn, $root_dir)
181  
182 =over 4
183  
184 =item return type: Client
185  
186 =item argument 1 type: Client::Connection
187  
188 A connection to the server which the client should use. It need not be
189 connected already.
190  
191 =item argument 2 type: string scalar
192  
193 The root directory of the CVS repository which the client should use.
194  
195 =back
196  
197 =cut
198  
199 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
200 0 my ($class, $conn, $root) = @_;
201 0 my $that = bless {}, $class;
202  
203 0 ▶ confess "First arg must be a VCS::LibCVS::Client::Connection"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conn and $conn->isa("VCS::LibCVS::Client::Connection") 0 0 0
Condition0%0/3
defined $conn and $conn->isa("VCS::LibCVS::Client::Connection")
!ll&&!rl&&r
000
MC/DC0%0/2
defined $conn and $conn->isa("VCS::LibCVS::Client::Connection")
defined $conn $conn->isa("VCS::LibCVS::Client::Connection")
Truth table0%0/3
A and B
A= defined $connB= $conn->isa("VCS::LibCVS::Client::Connection")
ABresult
0X0
100
111
204 unless (defined ($conn) && $conn->isa("VCS::LibCVS::Client::Connection"));
205  
206 0 $that->{Root} = $root;
207 0 $that->{Connection} = $conn;
208 0 $that->{Connected} = 0;
209 0 $that->{TestDir} = ".";
210  
211 # Initialize the default valid responses
212 0 $that->{ValidResponses} = {};
213 0 foreach my $response_name (@VCS::LibCVS::Client::Response::Valid_responses) {
214 0 $that->{ValidResponses}->{$response_name} = 0;
215 }
216 0 foreach my $response_name (VCS::LibCVS::Client::DEFAULT_VALID_RESPONSES) {
217 0 $that->{ValidResponses}->{$response_name} = 1;
218 }
219  
220 0 return $that;
221 }
222  
223 ###############################################################################
224 # Instance routines
225 ###############################################################################
226  
227 =head1 INSTANCE ROUTINES
228  
229 =head2 B<connect()>
230  
231 $client->connect()
232  
233 =over 4
234  
235 =item return type: undef
236  
237 =back
238  
239 Causes the Client to initiate a connection with the server, using the
240 parameters provided when it was constructed.
241  
242 First it establishes a connection to the server using its Connection object.
243 Then it performs an initial negotiation with the server, by issuing the
244 following requests:
245  
246 =over 4
247  
248 =item valid-requests
249  
250 Asks the server for a list of requests it supports. To find out what these
251 are, use the valid_requests() routine.
252  
253 =item Valid-responses
254  
255 Tells the server what responses this client supports. To configure these use
256 the valid_responses() routine.
257  
258 =item Root
259  
260 Tells the server which directory contains the repository we wish to use.
261  
262 =item UseUnchanged
263  
264 Tells the server which version of the protocol to use.
265  
266 =back
267  
268 =cut
269  
270 0 ▶sub connect {
Subroutine connect: not called CC=2 SCAR=17.9
Pod documented
271 0 my $self = shift;
272  
273 0 ▶ confess "Client already connected to $self->{Root}" if $self->{Connected};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Connected"} 0 0 0
274  
275 # Test if multiple commands can be supported on this connection.
276 0 $self->_test_support_multiple_commands();
277  
278 0 $self->_real_connect();
279  
280 0 $self->{Connected} = 1;
281  
282 0 return;
283 }
284  
285 =head2 B<disconnect()>
286  
287 $client->disconnect()
288  
289 =over 4
290  
291 =item return type: undef
292  
293 =back
294  
295 Disconnects this client from the server.
296  
297 =cut
298  
299 0 ▶sub disconnect {
Subroutine disconnect: not called CC=1 SCAR=6.9
Pod documented
300 0 my $self = shift;
301 0 $self->{Connection}->disconnect();
302 0 $self->{Connected} = 0;
303 0 return;
304 }
305  
306  
307 =head2 B<init_repository()>
308  
309 $client->init_repository()
310  
311 =over 4
312  
313 =item return type: undef
314  
315 =back
316  
317 Creates a new repository at the Root specified when the client was constructed.
318 The client must be disconnected when you call this routine.
319  
320 =cut
321  
322 0 ▶sub init_repository {
Subroutine init_repository: not called CC=3 SCAR=24.8
Pod documented
323 0 my $self = shift;
324  
325 0 ▶ confess "Must be disconnected to init a repository" if $self->{Connected};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Connected"} 0 0 0
326  
327 0 $self->{Connection}->connect();
328  
329 0 $self->_submit_valid_requests();
330  
331 0 my $init_request = VCS::LibCVS::Client::Request::init->new([ $self->{Root} ]);
332 0 my @responses = $self->submit_request($init_request);
333  
334 0 $self->{Connection}->disconnect();
335  
336 # Check that the init was a success
337 0 ▶ if (!(pop(@responses)->isa("VCS::LibCVS::Client::Response::ok"))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not pop(@responses)->isa("VCS::LibCVS::Client::Response::ok")) 0 0 0
338 0 my $errors = ""; map { $errors .= $_->get_errors(); } @responses;
339 0 confess "Init failed: $errors";
340 }
341 }
342  
343 =head2 B<submit_request()>
344  
345 @responses = $client->submit_request($request)
346  
347 =over 4
348  
349 =item return type: a list of Client::Response objects
350  
351 Returns responses in the order they were generated by the server. Some
352 requests do not generate a response, in which case this will be an empty list.
353 You can ask a Client::Request if it expects a response.
354  
355 =item argument 1 type: Client::Request
356  
357 An instance of a subclass of Client::Request. This must be a request type
358 which is supported by the server.
359  
360 =back
361  
362 Sends the request to the server, and returns any responses from the server. No
363 processing is done on the responses. The last request in the list will be an
364 ok or error response, so use the following to check if the request succeeded:
365  
366 C<pop(@responses)-E<gt>isa("VCS::LibCVS::Client::Response::ok")>
367  
368 =cut
369  
370 0 ▶sub submit_request {
Subroutine submit_request: not called CC=5 SCAR=34.0
Pod documented
371 0 my ($self, $request) = @_;
372  
373 confess "This request isn't supported by the server: " . $request->name()
374 0 ▶ unless $self->{ValidRequests}->{$request->name()};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"ValidRequests"}{$request->name} 0 0 0
375  
376 0 $request->protocol_print($self->{Connection}->get_ioh_to_server());
377  
378 0 ▶ return () if (!$request->response_expected());
Branch: 1 branch
BranchTrueFalseTotal
unless $request->response_expected 0 0 0
379  
380 0 my $in = $self->{Connection}->get_ioh_from_server();
381 0 my @resps = VCS::LibCVS::Client::Response->read_from_ioh($in);
382  
383 # If this was a command / argument using request, and the connection can't
384 # handle multiple commands, close and reopen it.
385  
386 0 ▶ if ( $self->{SingleCommand}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"SingleCommand"} and $request->isa("VCS::LibCVS::Client::Request::ArgumentUsingRequest")) 0 0 0
Condition0%0/3
$self->{"SingleCommand"} and $request->isa("VCS::LibCVS::Client::Request::ArgumentUsingRequest")
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"SingleCommand"} and $request->isa("VCS::LibCVS::Client::Request::ArgumentUsingRequest")
$self->{"SingleCommand"} $request->isa("VCS::LibCVS::Client::Request::ArgumentUsingRequest")
Truth table0%0/3
A and B
A= $self->{"SingleCommand"}B= $request->isa("VCS::LibCVS::Client::Request::ArgumentUsingRequest")
ABresult
0X0
100
111
387 && $request->isa("VCS::LibCVS::Client::Request::ArgumentUsingRequest")) {
388 0 $self->{Connection}->disconnect();
389 0 $self->_real_connect();
390 }
391  
392 0 return @resps;
393 }
394  
395 =head2 B<valid_responses()>
396  
397 $valid_responses = $client->valid_responses()
398  
399 =over 4
400  
401 =item return type: a hash ref containing the valid responses
402  
403 =back
404  
405 Returns a hash ref of supported responses, as it will be reported to the
406 server. What is sent to the server may be customized before opening the
407 connection.
408  
409 The keys of the hash are the names of the responses supported by the library,
410 and are not to be modified. The values are booleans and indicate whether or
411 not the client wants to report that response as valid, and may be modified.
412 The initial state of the hash has a pre-defined list of responses turned on,
413 those listed in the constant VCS::LibCVS::Client::DEFAULT_VALID_RESPONSES.
414  
415 =cut
416  
417 0 ▶sub valid_responses {
Subroutine valid_responses: not called CC=1 SCAR=6.9
Pod documented
418 0 my $self = shift;
419 0 return $self->{ValidResponses};
420 }
421  
422 =head2 B<valid_requests()>
423  
424 $valid_requests = $client->valid_requests()
425  
426 =over 4
427  
428 =item return type: a hash ref containing the names of the valid requests
429  
430 =back
431  
432 Returns a hash ref of requests supported by the server. This must be called
433 when the Client is connected to the server.
434  
435 The keys of the hash are the names of all the requests supported by either the
436 server or the client. The values are booleans indicating whether the
437 particular request is supported by the server.
438  
439 =cut
440  
441 0 ▶sub valid_requests {
Subroutine valid_requests: not called CC=1 SCAR=6.9
Pod documented
442 0 my $self = shift;
443 0 return $self->{ValidRequests};
444 }
445  
446 =head2 B<testing_dir()>
447  
448 $testing_dir = $client->testing_dir($any_repo_dir)
449  
450 =over 4
451  
452 =item return type: scalar string directory name. Relative or absolute.
453  
454 =back
455  
456 When a connection is created, the Client tests if the connection can support
457 multiple commands. This test requires a directory on the repository, in which
458 it can create a lock file. Unfortunately the root directory of the repository
459 is not always writable, so you can provide a directory which is writeable,
460 before the connection is made using this method.
461  
462 =cut
463  
464 0 ▶sub testing_dir {
Subroutine testing_dir: not called CC=2 SCAR=17.9
Pod documented
465 0 my $self = shift;
466 0 my $ntd = shift;
467 0 ▶ if ($ntd) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ntd) 0 0 0
468 0 $ntd =~ s/^$self->{Root}\///;
469 0 $self->{TestDir} = $ntd;
470 }
471 0 return $self->{TestDir};
472 }
473  
474 ###############################################################################
475 # Private routines
476 ###############################################################################
477  
478 # this routine submits the valid_requests request, and stores the results.
479 0 ▶sub _submit_valid_requests {
Subroutine _submit_valid_requests: not called CC=5 SCAR=34.0
480 0 my $self = shift;
481  
482 # initialize the ValidRequests variable with all the requests available in
483 # this implementation. We can't assume the server supports them
484 0 $self->{ValidRequests} = {};
485 0 foreach my $req_name (@VCS::LibCVS::Client::Request::Valid_requests) {
486 0 $self->{ValidRequests}->{$req_name} = 0;
487 }
488  
489 # bootstrap the request validity checking mechanism used in submit_request
490 0 $self->{ValidRequests}->{'valid-requests'} = 1;
491  
492 0 my $vrqs_request = VCS::LibCVS::Client::Request::valid_requests->new();
493 0 my @responses = $self->submit_request($vrqs_request);
494  
495 0 my $last_response = pop(@responses);
496 0 ▶ confess "valid_requests failed " . $last_response->data->[0]->as_string
Branch: 1 branch
BranchTrueFalseTotal
unless $last_response->isa("VCS::LibCVS::Client::Response::ok") and @responses == 1 0 0 0
Condition0%0/3
$last_response->isa("VCS::LibCVS::Client::Response::ok") and @responses == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$last_response->isa("VCS::LibCVS::Client::Response::ok") and @responses == 1
$last_response->isa("VCS::LibCVS::Client::Response::ok") @responses == 1
Truth table0%0/3
A and B
A= $last_response->isa("VCS::LibCVS::Client::Response::ok")B= @responses == 1
ABresult
0X0
100
111
497 unless ( $last_response->isa("VCS::LibCVS::Client::Response::ok")
498 && (@responses == 1));
499  
500 # Populate the ValidRequests hash with the results
501 0 foreach my $req_name (split /\s/, $responses[0]->data->[0]->as_string) {
502 0 $self->{ValidRequests}->{$req_name} = 1;
503 }
504  
505 0 return;
506 }
507  
508 # This does the actual work of connecting and doing initial negotiation with
509 # the server. to disconnect, call $self->{Connection}->disconnect();
510  
511 0 ▶sub _real_connect() {
Subroutine _real_connect: not called CC=3 SCAR=24.8
512 0 my $self = shift;
513  
514 0 $self->{Connection}->connect();
515  
516 # Get the server's valid requests
517 0 $self->_submit_valid_requests();
518  
519 # Tell the server what the valid responses are
520 0 my $vrsp_str = "";
521 0 ▶ while (my ($rsp_name, $on) = each %{$self->valid_responses}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$self->valid_responses;}) 0 0 0
522 0 ▶ $vrsp_str .= $rsp_name . " " if $on;
Branch: 1 branch
BranchTrueFalseTotal
if $on 0 0 0
523 }
524 0 my $vrsp = VCS::LibCVS::Client::Request::Valid_responses->new([$vrsp_str]);
525 0 $self->submit_request($vrsp);
526  
527 # Send the server my Root
528 0 my $root_request = VCS::LibCVS::Client::Request::Root->new([ $self->{Root} ]);
529 0 $self->submit_request($root_request);
530  
531 # Tell the server what version of the protocol to use via UseUnchanged
532 0 my $useu_request = VCS::LibCVS::Client::Request::UseUnchanged->new();
533 0 $self->submit_request($useu_request);
534 }
535  
536 # Tests if the server can support multiple commands on a single connection, and
537 # saves the result in a private variable. The client must be disconnected to
538 # call this routine.
539  
540 # This test is necessary because I have encountered broken loginfo scripts
541 # which cause all commands after the first to fail.
542  
543 0 ▶sub _test_support_multiple_commands {
Subroutine _test_support_multiple_commands: not called CC=10 SCAR=47.0
544 0 my $self = shift;
545  
546 0 $self->_real_connect();
547  
548 # Try to send the same command twice and see if it fails. I've chosen this
549 # command because it should be fast and not produce any output:
550 # rdiff -l -r HEAD
551  
552 # It would be nice to always perform this command at the root of the
553 # repository, ".". But a lock must be created which is not always possible,
554 # so instead a directory in which to perform it has been provided. However,
555 # sometimes this directory might not exist, through no fault of the user. To
556 # handle this eventuality, if the command fails, it is reattempted on the
557 # parents of the TestDirectory, until it succeeds, or it fails on the root of
558 # the repository.
559 0 my $test_dir = $self->{TestDir};
560  
561 0 my $arg_l = VCS::LibCVS::Client::Request::Argument->new("-l");
562 0 my $arg_r = VCS::LibCVS::Client::Request::Argument->new("-r");
563 0 my $arg_head = VCS::LibCVS::Client::Request::Argument->new("HEAD");
564 0 my $arg_dir;
565  
566 0 my $command = VCS::LibCVS::Client::Request::rdiff->new();
567  
568 0 while (1) {
569 0 $arg_dir = VCS::LibCVS::Client::Request::Argument->new($test_dir);
570  
571 0 $self->submit_request($arg_l);
572 0 $self->submit_request($arg_r);
573 0 $self->submit_request($arg_head);
574 0 $self->submit_request($arg_dir);
575 0 my @resps = $self->submit_request($command);
576  
577 0 ▶ if (($resps[-1]->isa("VCS::LibCVS::Client::Response::ok"))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($resps[-1]->isa('VCS::LibCVS::Client::Response::ok')) { } 0 0 0
578 0 last;
579 } else {
580 # The command failed.
581  
582 # If we reached the root, then there's nothing more to try, so fail.
583 0 ▶ if ($test_dir eq ".") {
Branch: 1 branch
BranchTrueFalseTotal
if ($test_dir eq ".") 0 0 0
584 0 my $errors;
585 0 ▶ foreach my $resp (@resps) { $errors .= ($resp->get_errors() || ""); };
Condition0%0/2
$resp->get_errors || ''
l!l
00
MC/DC0%0/1
$resp->get_errors || ''
$resp->get_errors
Truth table0%0/2
A
A= $resp->get_errors
Aresult
11
00
586 0 confess "Request failed: \"$errors\"";
587 }
588  
589 # Modify $test_dir to specify its parent, and try again.
590 0 ▶ if ($test_dir =~ "/") {
Branch: 1 branch
BranchTrueFalseTotal
if ($test_dir =~ m[/]) { } 0 0 0
591 0 $test_dir =~ s#(.*)/.*#$1#;
592 } else {
593 0 $test_dir = ".";
594 }
595 }
596 }
597  
598 # Attempt the command a second time.
599 0 $self->submit_request($arg_l);
600 0 $self->submit_request($arg_r);
601 0 $self->submit_request($arg_head);
602 0 $self->submit_request($arg_dir);
603 0 my @resps = $self->submit_request($command);
604  
605 0 $self->{Connection}->disconnect();
606  
607 0 $self->{SingleCommand} = 0;
608 0 ▶ if (($resps[-1]->isa("VCS::LibCVS::Client::Response::error"))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($resps[-1]->isa("VCS::LibCVS::Client::Response::error")) 0 0 0
609 0 $self->{SingleCommand} = 1;
610 }
611 0 ▶ if ($VCS::LibCVS::Client::DebugLevel & VCS::LibCVS::Client::DEBUG_OPTIONS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($VCS::LibCVS::Client::DebugLevel & 2) 0 0 0
612 0 my $cvsroot = $self->{Connection}->get_root()->as_string();
613 my $message = "LibCVS Client for $cvsroot " .
614 ($self->{SingleCommand}
615 0 ▶ ? "is using a new connection for each command"
Branch: 1 branch
BranchTrueFalseTotal
$self->{'SingleCommand'} ? : 0 0 0
616 : "is sending all commands over the same connection") . "\n";
617 0 ▶ if (defined $VCS::LibCVS::Client::DebugOut) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $VCS::LibCVS::Client::DebugOut) { } 0 0 0
618 0 open DEBUGOUT, ">> $VCS::LibCVS::Client::DebugOut";
619 0 print DEBUGOUT $message;
620 0 close DEBUGOUT;
621 } else {
622 0 print STDERR $message;
623 }
624 }
625 }
626  
627 1 1;
« blib/lib/VCS/LibCVS/WorkingFile.pm ↑ Summary blib/lib/VCS/LibCVS/RepositoryFileOrDirectory.pm »