VCI/VCS/Cvs/Directory.pm

filter: Statementstmt 28.5% 16 / 56 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 40.0% 4 / 10 Podpod 0.0% 0 / 1 totaltotal 22.7% 20 / 88 CC 12 SCAR 30.3
CC
12
Cov
21%
_build_x_cvs_dir
42.0
_build_contents
30.0
_build_time
6.0
CRAP 20.7
« VCI/VCS/Bzr/Commit.pm ↑ Summary VCI/VCS/Git/Commit.pm »
1 package VCI::VCS::Cvs::Directory;
2 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 extends 'VCI::Abstract::Directory';
4  
5 1 ▶use File::Path qw(mkpath);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use List::Util qw(maxstr);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Path::Abstract::Underload;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 has 'x_cvs_dir' => (is => 'ro', isa => 'Str', lazy_build => 1);
10  
11 0 ▶sub _build_revision { 'HEAD' }
Subroutine _build_revision: not called CC=1 SCAR=6.9
12 0 ▶sub _build_revno { shift->revision }
Subroutine _build_revno: not called CC=1 SCAR=6.9
13  
14 # XXX This should be optimized.
15 0 ▶sub _build_time {
Subroutine _build_time: not called CC=2 SCAR=17.9
16 0 my $self = shift;
17 0 my @files = grep($_->isa('VCI::Abstract::File'), @{$self->contents});
18 0 my @times = map { $_->time } @files;
19 0 ▶ return maxstr(@times) || 0;
Condition0%0/2
&maxstr(@times) || 0
l!l
00
MC/DC0%0/1
&maxstr(@times) || 0
&maxstr(@times)
Truth table0%0/2
A
A= &maxstr(@times)
Aresult
11
00
20 }
21  
22 # XXX Currently this may not return things with the proper revision.
23 0 ▶sub _build_contents {
Subroutine _build_contents: not called CC=5 SCAR=34.0
24 0 my $self = shift;
25 0 my $output = $self->vci->x_do(
26 args => ['-n', 'update', '-d'],
27 fromdir => $self->x_cvs_dir);
28 0 my @lines = split("\n", $output);
29 0 my @contents;
30 0 foreach my $line (@lines) {
31 0 ▶ next if $line =~ /^cvs update: Updating \.$/;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^cvs update: Updating \.$/ 0 0 0
32 0 ▶ if ($line =~ /^U (.*)$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($line =~ /^U (.*)$/) { } 0 0 0
elsif ($line =~ /New directory .(.+). -- ignored$/) { } 0 0 0
33 0 my $path = Path::Abstract::Underload->new($self->path, $1);
34 0 push(@contents, $self->file_class->new(
35 path => $path, project => $self->project,
36 parent => $self));
37 }
38 elsif ($line =~ /New directory .(.+). -- ignored$/) {
39 0 my $path = Path::Abstract::Underload->new($self->path, $1);
40 0 push(@contents, $self->directory_class->new(
41 path => $path, project => $self->project,
42 parent => $self));
43 }
44 else {
45 0 warn "Unparseable line during contents: $line";
46 }
47 }
48 0 return \@contents;
49 }
50  
51 # CVS doesn't really support listing files and directories from a remote
52 # connection. However, we can trick it into doing so with fake "CVS" dirs.
53 0 ▶sub _build_x_cvs_dir {
Subroutine _build_x_cvs_dir: not called CC=6 SCAR=37.4
54 0 my $self = shift;
55 0 my $dir = Path::Abstract::Underload->new($self->project->x_tmp, $self->path);
56 0 my $cvsdir = Path::Abstract::Underload->new($dir, 'CVS')->stringify;
57 0 ▶ if (!-d $cvsdir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $cvsdir) 0 0 0
58 0 mkpath($cvsdir);
59
60 0 ▶ open(my $root, ">$cvsdir/Root")
Branch: 1 branch
BranchTrueFalseTotal
open my $root, ">$cvsdir/Root" or confess("Failed to open $cvsdir/Root: $!") 0 0 0
61 || confess "Failed to open $cvsdir/Root: $!";
62 0 print $root $self->repository->root;
63 0 close($root);
64
65 0 my $repo_name = $self->project->name . '/' . $self->path->stringify;
66 # For local repos, you have to specify the full absolute path.
67 0 ▶ if ($self->repository->x_is_local) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->repository->x_is_local) 0 0 0
68 0 $repo_name = $self->repository->x_dir_part . '/' . $repo_name;
69 }
70 0 ▶ open(my $repository, ">$cvsdir/Repository")
Branch: 1 branch
BranchTrueFalseTotal
open my $repository, ">$cvsdir/Repository" or confess("Failed to open $cvsdir/Repository: $!") 0 0 0
71 || confess "Failed to open $cvsdir/Repository: $!";
72 0 print $repository $repo_name;
73 0 close($repository);
74
75 # Create a blank Entries file, or CVS complains.
76 0 ▶ open(my $entries, ">$cvsdir/Entries")
Branch: 1 branch
BranchTrueFalseTotal
open my $entries, ">$cvsdir/Entries" or confess("Failed to create $cvsdir/Entries: $!") 0 0 0
77 || confess "Failed to create $cvsdir/Entries: $!";;
78 0 close($entries);
79 }
80 0 return $dir->stringify;
81 }
82  
83 0 ▶sub DEMOLISH {
Subroutine DEMOLISH: not called CC=2 SCAR=17.9
Pod undocumented
84 0 my $self = shift;
85 0 ▶ File::Path::rmtree($self->x_cvs_dir) if defined $self->{x_cvs_dir};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"x_cvs_dir"} 0 0 0
86 }
87  
88 1 __PACKAGE__->meta->make_immutable;
89  
90 1 1;
« VCI/VCS/Bzr/Commit.pm ↑ Summary VCI/VCS/Git/Commit.pm »