blib/lib/Perl/Repository/APC.pm

filter: Statementstmt 9.1% 29 / 316 Branchbran 0.6% 1 / 146 Conditioncond 0.0% 0 / 33 MC/DCmcdc 0.0% 0 / 20 Subroutinesub 30.4% 7 / 23 Podpod 100% 12 / 12 totaltotal 8.9% 49 / 550 CC 103 SCAR 54.1
CC
103
Cov
6%
_apc_struct
582.7
closest
420.0
_splice_additional_tarballs
240.0
CRAP 224.1
« scripts/binsearchaperl ↑ Summary blib/lib/Perl/Repository/APC2SVN.pm »
1 package Perl::Repository::APC;
2  
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use Module::CoreList 2.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 13 my $Id = q$Id: APC.pm 317 2011-03-26 16:59:05Z k $;
11 # our $VERSION = sprintf "2.000_%03d", substr(q$Rev: 317 $,4);
12 13 our $VERSION = "2.002001";
13 13 $VERSION =~ s/_//;
14  
15 13 our %tarballs = (
16 "5.8.1" => {
17 tarfile => "perl-5.8.1.tar.gz",
18 },
19 "5.8.2" => {
20 tarfile => "perl-5.8.2.tar.gz",
21 },
22 "5.8.3" => {
23 tarfile => "perl-5.8.3.tar.gz",
24 },
25 "5.8.4" => {
26 tarfile => "perl-5.8.4.tar.gz",
27 },
28 "5.8.5" => {
29 tarfile => "perl-5.8.5.tar.gz",
30 },
31 "5.8.6" => {
32 tarfile => "perl-5.8.6.tar.gz",
33 },
34 "5.8.7" => {
35 tarfile => "perl-5.8.7.tar.gz",
36 },
37 "5.8.8" => {
38 tarfile => "perl-5.8.8.tar.gz",
39 },
40 "5.9.0" => {
41 tarfile => "perl-5.9.0.tar.gz",
42 },
43 "5.9.1" => {
44 tarfile => "perl-5.9.1.tar.gz",
45 },
46 "5.9.2" => {
47 tarfile => "perl-5.9.2.tar.gz",
48 },
49 "5.9.3" => {
50 tarfile => "perl-5.9.3.tar.gz",
51 },
52 "5.9.4" => {
53 tarfile => "perl-5.9.4.tar.gz",
54 },
55 "5.9.5" => {
56 tarfile => "perl-5.9.5.tar.gz",
57 },
58 "5.10.0" => {
59 tarfile => "perl-5.10.0.tar.gz",
60 },
61 );
62  
63 1 ▶sub new {
Subroutine new: called CC=3 SCAR=18.8
Pod documented
64 1 ▶ unless (@_ == 2){
Branch: 1 branch
BranchTrueFalseTotal
unless (@_ == 2) 1 0 1
65 1 require Carp;
66 1 Carp::croak(sprintf "Not enough arguments for %s -> new ()\n", __PACKAGE__);
67 }
68 0 my $proto = shift;
69 0 ▶ my $class = ref $proto || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
70  
71 0 my $dir = shift;
72 0 my $self;
73  
74 0 $self->{DIR} = $dir;
75 0 $self->{APC} = [_apc_struct($dir)];
76  
77 0 bless $self => $class;
78 }
79  
80 0 ▶sub apcdirs {
Subroutine apcdirs: not called CC=1 SCAR=6.9
Pod documented
81 0 my($self) = @_;
82 0 @{$self->{APC}};
83 }
84  
85 0 ▶sub tarball {
Subroutine tarball: not called CC=6 SCAR=37.4
Pod documented
86 0 ▶ unless (@_ == 2){
Branch: 1 branch
BranchTrueFalseTotal
unless (@_ == 2) 0 0 0
87 0 require Carp;
88 0 Carp::croak(sprintf "Not enough arguments for %s -> tarball ()\n", __PACKAGE__);
89 }
90 0 my($self,$pver) = @_;
91 0 ▶ unless ($pver){
Branch: 1 branch
BranchTrueFalseTotal
unless ($pver) 0 0 0
92 0 require Carp;
93 0 Carp::croak(sprintf "No version argument for %s -> tarball ()\n", __PACKAGE__);
94 }
95  
96 0 my $DIR = File::Spec->catdir($self->{DIR},$pver);
97 0 my $dir;
98 0 ▶ unless (opendir $dir, $DIR) {
Branch: 1 branch
BranchTrueFalseTotal
unless (opendir $dir, $DIR) 0 0 0
99 0 return $self->_from_additional_tarballs($pver);
100 }
101 0 my(@dirent) = grep !/RC|TRIAL/, grep /^perl.*\.tar\.gz$/, readdir $dir;
102 0 closedir $dir;
103 0 ▶ if (@dirent>1){
Branch: 2 branches
BranchTrueFalseTotal
if (@dirent > 1) { } 0 0 0
elsif (@dirent == 0) { } 0 0 0
104 0 die "\aALERT: (\@dirent > 1: @dirent) in $pver" ;
105 } elsif (@dirent==0) {
106 0 return $self->_from_additional_tarballs($pver);
107 }
108 0 $dirent[0];
109 }
110  
111 0 ▶sub _from_additional_tarballs {
Subroutine _from_additional_tarballs: not called CC=3 SCAR=24.8
112 0 my($self,$pver) = @_;
113 0 ▶ die "unsupported perl version '$pver'", unless exists $tarballs{$pver};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Perl::Repository::APC::tarballs{$pver} 0 0 0
114 0 my $tarball = $tarballs{$pver}{tarfile};
115 0 my $cwd = Cwd::cwd();
116 my $addltar = File::Spec->catfile
117 (
118 $self->{DIR},
119 0 "additional_tarballs",
120 $tarball,
121 );
122 0 ▶ if (-f $addltar){
Branch: 1 branch
BranchTrueFalseTotal
if (-f $addltar) { } 0 0 0
123 0 return $addltar;
124 } else {
125 0 die "tarball '$tarball' not found. Have you mirrored the additional_tarballs directory?\n";
126 }
127 }
128  
129 0 ▶sub patches {
Subroutine patches: not called CC=4 SCAR=30.0
Pod documented
130 0 my($self,$ver) = @_;
131 0 ▶ unless ($ver) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ver) 0 0 0
132 0 require Carp;
133 0 Carp::confess("patches called without ver[$ver]");
134 }
135 0 my @res;
136 0 for my $apcdir (@{$self->{APC}}) {
137 0 my $pver = $apcdir->{perl};
138 0 ▶ next unless $pver eq $ver;
Branch: 1 branch
BranchTrueFalseTotal
unless $pver eq $ver 0 0 0
139 0 @res = @{$apcdir->{patches}};
140 0 last;
141 }
142 0 \@res;
143 }
144  
145 0 ▶sub first_in_branch {
Subroutine first_in_branch: not called CC=3 SCAR=24.8
Pod documented
146 0 my($self,$branch) = @_;
147 0 ▶ unless (exists $self->{FIRST_IN_BRANCH}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"FIRST_IN_BRANCH"}) 0 0 0
148 0 $self->next_in_branch; # initialize
149 }
150 0 my $ret = $self->{FIRST_IN_BRANCH}{$branch};
151 0 ▶ die "Unknown branch" unless $ret;
Branch: 1 branch
BranchTrueFalseTotal
unless $ret 0 0 0
152 0 $ret;
153 }
154  
155 0 ▶sub next_in_branch {
Subroutine next_in_branch: not called CC=6 SCAR=37.4
Pod documented
156 0 my($self,$ver) = @_;
157 0 ▶ if (not exists $self->{NEXT_IN_BRANCH}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"NEXT_IN_BRANCH"}) 0 0 0
158 0 my %L = ();
159 0 for my $apcdir (@{$self->{APC}}) {
160 0 my $pbranch = $apcdir->{branch};
161 0 my $pver = $apcdir->{perl};
162 0 $self->{NEXT_IN_BRANCH}{$pver} = [$pbranch]; # only for the last
163 0 ▶ if ($L{$pbranch}){
Branch: 1 branch
BranchTrueFalseTotal
if ($L{$pbranch}) { } 0 0 0
164 0 $self->{NEXT_IN_BRANCH}{$L{$pbranch}} = [$pbranch,$pver];
165 } else {
166 0 $self->{FIRST_IN_BRANCH}{$pbranch} = $pver;
167 }
168 0 $L{$pbranch} = $pver;
169 }
170 }
171 0 ▶ return unless $ver;
Branch: 1 branch
BranchTrueFalseTotal
unless $ver 0 0 0
172 0 my $ref = $self->{NEXT_IN_BRANCH}{$ver};
173 0 ▶ die "Unknown perl version $ver\n" unless $ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 0 0 0
174 0 my($rbranch,$rver) = @$ref;
175 # warn "rver[$rver] rbranch[$rbranch]";
176 0 $rver;
177 }
178  
179 0 ▶sub get_to_version {
Subroutine get_to_version: not called CC=4 SCAR=30.0
Pod documented
180 0 ▶ die "Usage: ->get_to_version(\$branch,\$patch)" unless @_ == 3;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
181 0 my($self,$branch,$patch) = @_;
182 0 ▶ unless ($patch) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($patch) 0 0 0
183 0 require Carp;
184 0 Carp::confess("get_to_version called without patch[$patch]");
185 }
186 0 my $bp2v = $self->_bp2v;
187 0 my $ret = $bp2v->{$branch,$patch};
188 0 ▶ unless ($ret){
Branch: 1 branch
BranchTrueFalseTotal
unless ($ret) 0 0 0
189 0 require Carp;
190 0 Carp::confess("patch[$patch] not part of branch[$branch]");
191 }
192 0 $ret;
193 }
194  
195 0 ▶sub get_diff_dir {
Subroutine get_diff_dir: not called CC=7 SCAR=40.3
Pod documented
196 0 ▶ die "Usage: ->get_diff_dir(\$branch,\$patch)" unless @_ == 3;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
197 0 my($self,$branch,$patch) = @_;
198 0 my $perl = $self->get_to_version($branch,$patch);
199 0 my $dir = $self->{PERL2DIR}{$perl};
200 0 ▶ return $dir if $dir;
Branch: 1 branch
BranchTrueFalseTotal
if $dir 0 0 0
201 0 my @apc = @{$self->{APC}};
202 0 for my $apcdir (@apc) {
203 0 my($dir) = $apcdir->{dir};
204 0 my $abs = File::Spec->catdir($self->{DIR},$dir);
205 0 ▶ unless (-d $abs) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $abs) 0 0 0
206 0 $dir = $apcdir->{diffdir};
207 0 $abs = File::Spec->catdir($self->{DIR},$dir);
208 0 ▶ unless (-d $abs) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $abs) 0 0 0
209 0 warn "WARNING: directory '$abs' not found";
210 }
211 }
212 0 my($perl) = $apcdir->{perl};
213 0 $self->{PERL2DIR}{$perl} = $dir;
214 }
215 0 ▶ die "could not find dir for perl '$self->{PERL2DIR}{$perl}'" unless $self->{PERL2DIR}{$perl};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"PERL2DIR"}{$perl} 0 0 0
216 0 return $self->{PERL2DIR}{$perl};
217 }
218  
219 0 ▶sub _bp2v {
Subroutine _bp2v: not called CC=4 SCAR=30.0
220 0 my $self = shift;
221 0 ▶ unless ($self->{BP2V}) { # branch/patch to version mapping
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"BP2V"}) 0 0 0
222 0 my @apc = @{$self->{APC}};
223 0 for my $apcdir (@apc) {
224 0 my($apc_branch) = $apcdir->{branch};
225 0 my($pver) = $apcdir->{perl};
226 0 my($patches) = $apcdir->{patches};
227 0 for my $p (@$patches) {
228 0 $self->{BP2V}{$apc_branch,$p} = $pver;
229 }
230 }
231 }
232 0 $self->{BP2V};
233 }
234  
235 0 ▶sub get_from_version {
Subroutine get_from_version: not called CC=7 SCAR=40.3
Pod documented
236 0 my($self) = shift;
237 0 my($branch,$patch) = @_;
238 0 ▶ unless ($patch) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($patch) 0 0 0
239 0 require Carp;
240 0 ▶ $patch = "[undef]" unless defined $patch;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $patch 0 0 0
241 0 Carp::confess("get_from_version called without patch[$patch]");
242 }
243 0 my $perl = $self->get_to_version(@_);
244 0 my @apc = @{$self->{APC}};
245 0 my %Ldir = ( "perl" => 0, "maint-5.004" => 0 );
246 0 for my $apc (@apc) {
247 0 my($apc_branch) = $apc->{branch};
248 0 ▶ next unless $apc_branch eq $branch;
Branch: 1 branch
BranchTrueFalseTotal
unless $apc_branch eq $branch 0 0 0
249 0 my($pver) = $apc->{perl};
250 0 ▶ if ($pver eq $perl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pver eq $perl) 0 0 0
251 0 ▶ if (exists $Ldir{$apc_branch}){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $Ldir{$apc_branch}) { } 0 0 0
252 0 return $Ldir{$apc_branch};
253 } else {
254 0 $perl =~ s/1$/0/;
255 0 return $perl;
256 }
257 }
258 0 $Ldir{$apc_branch} = $pver;
259 }
260 }
261  
262 {
263 13 my %ignore = map { ($_ => undef) } qw(4475 32694);
264 0 ▶ sub _ignore_patch_number ($) {
Subroutine _ignore_patch_number: not called CC=1 SCAR=6.9
265 0 my($patch_number) = @_;
266 0 return exists $ignore{$patch_number};
267 }
268 }
269  
270 13 ▶sub _apc_struct ($) {
Subroutine _apc_struct: not called CC=24 SCAR=63.7
271 0 my $APC = shift;
272 0 ▶ opendir my $APCDH, $APC or die "Could not open APC[$APC]: $!";
Branch: 1 branch
BranchTrueFalseTotal
opendir my $APCDH, $APC or die "Could not open APC[$APC]: $!" 0 0 0
273 0 my @apcdir;
274 my %dseen;
275 0 my %living_dirs = (
276 # all the "old" symlinks
277  
278 ## % ls -ld APC/*/diffs(@)
279 ## lrwxrwxrwx 1 sand sand 21 2005-06-09 06:34:12 APC/5.005_04/diffs -> ../perl-5.005xx-diffs/
280 ## lrwxrwxrwx 1 sand sand 19 2008-01-19 15:48:04 APC/5.6.2/diffs -> ../perl-5.6.2-diffs/
281 ## lrwxrwxrwx 1 sand sand 19 2008-01-19 15:48:04 APC/5.6.3/diffs -> ../perl-5.6.x-diffs/
282 ## lrwxrwxrwx 1 sand sand 19 2008-01-19 15:48:04 APC/5.8.1/diffs -> ../perl-5.8.x-diffs/
283 ## lrwxrwxrwx 1 sand sand 21 2008-01-19 15:48:04 APC/5.9.0/diffs -> ../perl-current-diffs/
284  
285 "5.005_04" => "perl-5.005xx-diffs",
286 "5.6.2" => "perl-5.6.2-diffs",
287 "5.6.3" => "perl-5.6.x-diffs",
288 "5.8.1" => "perl-5.8.x-diffs",
289 "5.9.0" => "perl-current-diffs",
290
291 # plus the not symlinked ones
292 "5.10.1" => "perl-5.10.x-diffs",
293 );
294 0 my %have_visited;
295 0 DIRENT: for my $dirent (readdir $APCDH, keys %living_dirs) {
296 0 ▶ next DIRENT unless $dirent =~ /^5/;
Branch: 1 branch
BranchTrueFalseTotal
unless $dirent =~ /^5/ 0 0 0
297 0 my $diffdir;
298 0 ▶ if (my $living_dir = $living_dirs{$dirent}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $living_dir = $living_dirs{$dirent}) { } 0 0 0
299 0 $diffdir = File::Spec->catdir($APC,$living_dir);
300 0 ▶ unless (-e $diffdir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $diffdir) 0 0 0
301 0 my $fallback = File::Spec->catdir($APC,$dirent,"diffs");
302 0 warn "Warning: expected to find '$diffdir', trying '$fallback'";
303 0 $diffdir = $fallback;
304 }
305 } else {
306 0 $diffdir = File::Spec->catdir($APC,$dirent,"diffs");
307 }
308 0 ▶ if ($have_visited{$dirent,$diffdir}++){
Branch: 1 branch
BranchTrueFalseTotal
if ($have_visited{join $;, $dirent, $diffdir}++) 0 0 0
309 # again is OK if for a different thing
310 # warn "DEBUG: skipping '$diffdir' due to '$dirent'";
311 0 next DIRENT;
312 }
313 0 ▶ opendir my $DIFFDIR, $diffdir or die "Could not open $diffdir: $!";
Branch: 1 branch
BranchTrueFalseTotal
opendir my $DIFFDIR, $diffdir or die "Could not open ${diffdir}: $!" 0 0 0
314 0 my %patches;
315 # read them and give them a value
316 0 PFILE: for my $dirent2 (readdir $DIFFDIR) {
317 0 ▶ next PFILE unless $dirent2 =~ /^(\d+)\.gz/;
Branch: 1 branch
BranchTrueFalseTotal
unless $dirent2 =~ /^(\d+)\.gz/ 0 0 0
318 0 my $candnu = $1;
319 0 ▶ next PFILE if _ignore_patch_number($candnu);
Branch: 1 branch
BranchTrueFalseTotal
if &_ignore_patch_number($candnu) 0 0 0
320 0 $patches{$dirent2} = $candnu;
321 0 ▶ if ($dseen{$dirent2}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dseen{$dirent2}) { } 0 0 0
322 # warn "Duplicate $dirent2 in $diffdir (also in $dseen{$dirent2})\n";
323 } else {
324 0 $dseen{$dirent2} = $diffdir;
325 }
326 }
327 0 closedir $DIFFDIR;
328 0 ▶ unless (%patches){ # in case they did not mirror something we try to drop it silently
Branch: 1 branch
BranchTrueFalseTotal
unless (%patches) 0 0 0
329 # warn "DEBUG: skipping '$dirent' because no entry";
330 0 next DIRENT;
331 }
332 0 ▶ my @patches = sort { $patches{$a} <=> $patches{$b} || $a cmp $b } keys %patches;
Condition0%0/3
$patches{$a} <=> $patches{$b} || $a cmp $b
l!l&&r!l&&!r
000
MC/DC0%0/2
$patches{$a} <=> $patches{$b} || $a cmp $b
$patches{$a} <=> $patches{$b} $a cmp $b
Truth table0%0/3
A || B
A= $patches{$a} <=> $patches{$b}B= $a cmp $b
ABresult
1X1
011
000
333 0 my $branch;
334 my $sortdummy;
335 0 PATCH: for my $n (0..$#patches) {
336 0 my $diff;
337 0 ▶ die unless -e ($diff = File::Spec->catfile($diffdir,$patches[$n]));
Branch: 1 branch
BranchTrueFalseTotal
unless -e ($diff = "File::Spec"->catfile($diffdir, $patches[$n])) 0 0 0
338 0 ▶ ($sortdummy) = $patches[$n] =~ /(\d+)/ unless $sortdummy;
Branch: 1 branch
BranchTrueFalseTotal
unless $sortdummy 0 0 0
339 0 ▶ open my $fh, "zcat $diff |" or die;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "zcat $diff |" or die 0 0 0
340 0 local($/) = "\n";
341 0 ▶ LINE: while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
342 0 ▶ next LINE unless m|^==== //depot/([^/]+)/([^/]+)|;
Branch: 1 branch
BranchTrueFalseTotal
unless m[^==== //depot/([^/]+)/([^/]+)] 0 0 0
343 0 $branch = $1;
344 0 my $subbranch = $2; # this limits us to one level. Unlucky.
345 0 ▶ next LINE unless $branch =~ /maint/;
Branch: 1 branch
BranchTrueFalseTotal
unless $branch =~ /maint/ 0 0 0
346 0 ▶ $branch .= "/$subbranch" unless $subbranch eq "perl";
Branch: 1 branch
BranchTrueFalseTotal
unless $subbranch eq "perl" 0 0 0
347 0 last LINE;
348 # print "$dirent|$patches[0]: $_";
349 }
350 0 close $fh;
351 0 ▶ if ($branch) {
Branch: 1 branch
BranchTrueFalseTotal
if ($branch) 0 0 0
352 0 last PATCH;
353 }
354 }
355 0 my $reldiffdir = File::Spec->abs2rel($diffdir, $APC);
356 0 ▶ unless ($reldiffdir) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reldiffdir) 0 0 0
357 0 warn "DEBUG: no reldiffdir??? dirent[$dirent]diffdir[$diffdir]";
358 }
359 push @apcdir, {branch => $branch,
360 dir => $dirent,
361 diffdir => $reldiffdir,
362 perl => $dirent,
363 0 patches => [map {$patches{$patches[$_]}} 0..$#patches],
364 };
365 }
366 0 closedir $APCDH;
367 0 _splice_additional_tarballs(\@apcdir);
368 0 sort { $a->{patches}[-1] <=> $b->{patches}[-1] } @apcdir;
369 }
370  
371 0 ▶sub _splice_additional_tarballs ($) {
Subroutine _splice_additional_tarballs: not called CC=15 SCAR=54.8
372 0 my($apcdir) = @_;
373 0 my @splicers;
374 0 ▶ while (my($k,$v) = each %tarballs) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %Perl::Repository::APC::tarballs) 0 0 0
375 0 my $version = version->new($k)->numify + 0;
376 0 ▶ my $x = $Module::CoreList::patchlevel{$version}
Branch: 1 branch
BranchTrueFalseTotal
my $x = $Module::CoreList::patchlevel{$version} or die qq[could not access corelist for '${version}' from '$INC{"Module/CoreList.pm"}'] 0 0 0
377 or die "could not access corelist for '$version' from '$INC{'Module/CoreList.pm'}'";
378 0 push @splicers, {
379 branch => $x->[0],
380 patchlevel => $x->[1],
381 perl => $k,
382 };
383 }
384 0 my $success = 0;
385 0 for my $splicer (sort {$a->{branch} cmp $b->{branch}
386 ||
387 $a->{patchlevel} <=> $b->{patchlevel}
388 0 ▶ } @splicers) {
Condition0%0/3
$Perl::Repository::APC::a->{'branch'} cmp $Perl::Repository::APC::b->{'branch'} || $Perl::Repository::APC::a->{'patchlevel'} <=> $Perl::Repository::APC::b->{'patchlevel'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Perl::Repository::APC::a->{'branch'} cmp $Perl::Repository::APC::b->{'branch'} || $Perl::Repository::APC::a->{'patchlevel'} <=> $Perl::Repository::APC::b->{'patchlevel'}
$Perl::Repository::APC::a->{'branch'} cmp $Perl::Repository::APC::b->{'branch'} $Perl::Repository::APC::a->{'patchlevel'} <=> $Perl::Repository::APC::b->{'patchlevel'}
Truth table0%0/3
A || B
A= $Perl::Repository::APC::a->{'branch'} cmp $Perl::Repository::APC::b->{'branch'}B= $Perl::Repository::APC::a->{'patchlevel'} <=> $Perl::Repository::APC::b->{'patchlevel'}
ABresult
1X1
011
000
389 0 APCDIR: for my $i (0..$#$apcdir) {
390 0 my $beq = $apcdir->[$i]{branch} eq $splicer->{branch};
391 0 my $peq = version->new($splicer->{perl}) >= version->new($apcdir->[$i]{perl});
392 0 my $lok = $splicer->{patchlevel} > $apcdir->[$i]{patches}[0];
393 0 my $rok = $splicer->{patchlevel} <= $apcdir->[$i]{patches}[-1];
394 0 ▶ if ($beq && $peq && $lok && $rok) {
Branch: 1 branch
BranchTrueFalseTotal
if ($beq and $peq and $lok and $rok) 0 0 0
Condition0%0/9
$beq and $peq and $lok and $rok
!ll&&!rl&&r
000
$beq and $peq and $lok
!ll&&!rl&&r
000
$beq and $peq
!ll&&!rl&&r
000
MC/DC0%0/4
$beq and $peq and $lok and $rok
$beq $peq $lok $rok
Truth table0%0/5
A and B and C and D
A= $beqB= $peqC= $lokD= $rok
ABCDresult
0XXX0
10XX0
110X0
11100
11111
395 0 my $adir = splice @$apcdir, $i, 1;
396 # the left range is leading to $version_popular
397 # the right range is leading to what it already states
398 0 my(%left, %right);
399 0 for ("branch","dir","diffdir") {
400 0 $left{$_} = $right{$_} = $adir->{$_};
401 }
402 0 ▶ if ($splicer->{perl} eq $adir->{perl}){
Branch: 1 branch
BranchTrueFalseTotal
if ($splicer->{"perl"} eq $adir->{"perl"}) 0 0 0
403 # we cannot have two perls with the same name.
404 0 $adir->{perl} .= ".1"; # ouch
405 }
406 0 $left{perl} = $splicer->{perl};
407 0 $right{perl} = $adir->{perl};
408 0 $left{patches} = [];
409 0 $right{patches} = [];
410 0 ▶ push @{$left{patches}}, shift @{$adir->{patches}} while $adir->{patches}[0] <= $splicer->{patchlevel};
Branch: 1 branch
BranchTrueFalseTotal
$adir->{"patches"}[0] <= $splicer->{"patchlevel"} and do { push @{$left{"patches"};}, shift @{$$adir{"patches"};} } 0 0 0
411 0 $right{patches} = $adir->{patches};
412 0 push @$apcdir, \%left, \%right;
413 0 last APCDIR;
414 }
415 }
416 }
417 0 my %rename = (
418 "5.8.1.1" => "5.8.9",
419 "5.9.0.1" => "5.11.0",
420 );
421 0 APCDIR: for my $i (0..$#$apcdir) {
422 0 my $perl = $apcdir->[$i]{perl};
423 0 ▶ if (my $rename = $rename{$perl}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $rename = $rename{$perl}) 0 0 0
424 0 $apcdir->[$i]{perl} = $rename;
425 }
426 }
427 }
428  
429 0 ▶sub version_range {
Subroutine version_range: not called CC=5 SCAR=34.0
Pod documented
430 0 my($self,$branch,$lo,$hi) = @_;
431 0 $lo = $self->closest($branch,">",$lo);
432 0 $hi = $self->closest($branch,"<",$hi);
433 0 my @range;
434 0 my @apc = @{$self->{APC}};
435 0 for my $apcdir (@apc) {
436 0 my($apc_branch) = $apcdir->{branch};
437 0 my($pver) = $apcdir->{perl};
438 0 my($patches) = $apcdir->{patches};
439 0 ▶ next unless $apc_branch eq $branch;
Branch: 1 branch
BranchTrueFalseTotal
unless $apc_branch eq $branch 0 0 0
440 0 ▶ next unless $lo <= $patches->[-1];
Branch: 1 branch
BranchTrueFalseTotal
unless $lo <= $patches->[-1] 0 0 0
441 0 ▶ last if $hi < $patches->[0];
Branch: 1 branch
BranchTrueFalseTotal
if $hi < $patches->[0] 0 0 0
442 0 push @range, $pver;
443 }
444 0 \@range;
445 }
446  
447 0 ▶sub patch_range {
Subroutine patch_range: not called CC=6 SCAR=37.4
Pod documented
448 0 my($self,$branch,$lo,$hi) = @_;
449 0 my($vrange,%vrange);
450 0 $vrange = $self->version_range($branch,$lo,$hi);
451 0 @vrange{@$vrange} = ();
452 0 my @range;
453 0 my @apc = @{$self->{APC}};
454 0 for my $apcdir (@apc) {
455 0 ▶ next unless exists $vrange{$apcdir->{perl}};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $vrange{$apcdir->{"perl"}} 0 0 0
456 0 my($patches) = $apcdir->{patches};
457 0 for my $p (@$patches) {
458 0 ▶ if ($p >= $lo && $p <= $hi) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p >= $lo and $p <= $hi) 0 0 0
Condition0%0/3
$p >= $lo and $p <= $hi
!ll&&!rl&&r
000
MC/DC0%0/2
$p >= $lo and $p <= $hi
$p >= $lo $p <= $hi
Truth table0%0/3
A and B
A= $p >= $loB= $p <= $hi
ABresult
0X0
100
111
459 0 push @range, $p;
460 }
461 }
462 }
463 0 \@range;
464 }
465  
466 0 ▶sub closest {
Subroutine closest: not called CC=20 SCAR=60.4
Pod documented
467 0 my($self,$branch,$alt,$wanted) = @_;
468 0 my $closest;
469 0 ▶ if ($alt eq "<") {
Branch: 1 branch
BranchTrueFalseTotal
if ($alt eq '<') { } 0 0 0
470 0 $closest = 0;
471 } else {
472 0 $closest = 999999999;
473 }
474 0 my @apc = @{$self->{APC}};
475 0 for my $i (0..$#apc) {
476 0 my $apcdir = $apc[$i];
477 0 my($apc_branch) = $apcdir->{branch};
478 0 my($pver) = $apcdir->{perl};
479 0 my $patches = $apcdir->{patches};
480 0 ▶ next unless $apc_branch eq $branch;
Branch: 1 branch
BranchTrueFalseTotal
unless $apc_branch eq $branch 0 0 0
481 0 ▶ next if $alt eq ">" && $patches->[-1] < $wanted;
Branch: 1 branch
BranchTrueFalseTotal
if $alt eq ">" and $patches->[-1] < $wanted 0 0 0
Condition0%0/3
$alt eq ">" and $patches->[-1] < $wanted
!ll&&!rl&&r
000
MC/DC0%0/2
$alt eq ">" and $patches->[-1] < $wanted
$alt eq ">" $patches->[-1] < $wanted
Truth table0%0/3
A and B
A= $alt eq ">"B= $patches->[-1] < $wanted
ABresult
0X0
100
111
482 0 ▶ next if $alt eq "<" && $patches->[0] > $wanted;
Branch: 1 branch
BranchTrueFalseTotal
if $alt eq "<" and $patches->[0] > $wanted 0 0 0
Condition0%0/3
$alt eq "<" and $patches->[0] > $wanted
!ll&&!rl&&r
000
MC/DC0%0/2
$alt eq "<" and $patches->[0] > $wanted
$alt eq "<" $patches->[0] > $wanted
Truth table0%0/3
A and B
A= $alt eq "<"B= $patches->[0] > $wanted
ABresult
0X0
100
111
483 0 ▶ if ($alt eq ">" && $patches->[0] > $wanted){
Branch: 2 branches
BranchTrueFalseTotal
if ($alt eq '>' and $patches->[0] > $wanted) { } 0 0 0
elsif ($alt eq '<' and $patches->[-1] < $wanted) { } 0 0 0
Condition0%0/3
$alt eq ">" and $patches->[0] > $wanted
!ll&&!rl&&r
000
MC/DC0%0/2
$alt eq ">" and $patches->[0] > $wanted
$alt eq ">" $patches->[0] > $wanted
Truth table0%0/3
A and B
A= $alt eq ">"B= $patches->[0] > $wanted
ABresult
0X0
100
111
484 0 ▶ $closest = $patches->[0] if $closest > $patches->[0];
Branch: 1 branch
BranchTrueFalseTotal
if $closest > $patches->[0] 0 0 0
485 0 last;
486 ▶ } elsif ($alt eq "<" && $patches->[-1] < $wanted) {
Condition0%0/3
$alt eq "<" and $patches->[-1] < $wanted
!ll&&!rl&&r
000
MC/DC0%0/2
$alt eq "<" and $patches->[-1] < $wanted
$alt eq "<" $patches->[-1] < $wanted
Truth table0%0/3
A and B
A= $alt eq "<"B= $patches->[-1] < $wanted
ABresult
0X0
100
111
487 0 $closest = $patches->[-1];
488 0 next;
489 }
490 0 for my $p (@$patches) {
491 0 ▶ if ($alt eq "<") {
Branch: 1 branch
BranchTrueFalseTotal
if ($alt eq '<') { } 0 0 0
492 0 ▶ last if $p > $wanted;
Branch: 1 branch
BranchTrueFalseTotal
if $p > $wanted 0 0 0
493 0 $closest = $p;
494 } else {
495 0 ▶ $closest = $p, last if $p >= $wanted;
Branch: 1 branch
BranchTrueFalseTotal
if $p >= $wanted 0 0 0
496 }
497 }
498 }
499 0 ▶ if ($alt eq "<") {
Branch: 1 branch
BranchTrueFalseTotal
if ($alt eq '<') { } 0 0 0
500 0 ▶ if ($closest == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($closest == 0) 0 0 0
501 0 die "Could not find a patch > 0 and < $wanted";
502 }
503 } else {
504 0 ▶ if ($closest == 999999999) {
Branch: 1 branch
BranchTrueFalseTotal
if ($closest == 999999999) 0 0 0
505 0 die "Could not find a patch < 999999999 and > $wanted";
506 }
507 }
508 0 $closest;
509 }
510  
511 13 1;
512  
513 __END__
« scripts/binsearchaperl ↑ Summary blib/lib/Perl/Repository/APC2SVN.pm »