VCI/VCS/Bzr/Commit.pm

filter: Statementstmt 18.3% 11 / 60 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 20.0% 2 / 10 Podpod n/a totaltotal 14.4% 13 / 90 CC 14 SCAR 32.0
CC
14
Cov
14%
_build_x_changes
42.0
_x_parse_renamed
30.0
_x_parse_items
30.0
CRAP 24.5
« VCI/VCS/Git/Directory.pm ↑ Summary VCI/VCS/Cvs/Directory.pm »
1 package VCI::VCS::Bzr::Commit;
2 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 extends 'VCI::Abstract::Commit';
4  
5 1 ▶use XML::Simple qw(:strict);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 has 'x_changes' => (is => 'ro', isa => 'HashRef', lazy_build => 1);
8 1 has '+revno' => (required => 1);
9  
10 0 ▶sub _build_as_diff {
Subroutine _build_as_diff: not called CC=1 SCAR=6.9
11 0 my $self = shift;
12 0 my $rev = $self->revision;
13 0 my $proj_path = $self->repository->root . $self->project->name;
14 0 my $diff = $self->vci->x_do(
15 args => ['diff', "--change=revid:$rev", $proj_path],
16 errors_ignore => [1, 256]);
17 0 return $self->diff_class->new(raw => $diff, project => $self->project);
18 }
19  
20 0 ▶sub _build_added { shift->x_changes->{added} }
Subroutine _build_added: not called CC=1 SCAR=6.9
21 0 ▶sub _build_removed { shift->x_changes->{removed} }
Subroutine _build_removed: not called CC=1 SCAR=6.9
22 0 ▶sub _build_modified { shift->x_changes->{modified} }
Subroutine _build_modified: not called CC=1 SCAR=6.9
23 0 ▶sub _build_moved { shift->x_changes->{moved} }
Subroutine _build_moved: not called CC=1 SCAR=6.9
24  
25 0 ▶sub _build_x_changes {
Subroutine _build_x_changes: not called CC=6 SCAR=37.4
26 0 my $self = shift;
27 0 my $proj_path = $self->repository->root . $self->project->name;
28 0 my $xml_string = $self->vci->x_do(
29 args => [qw(log -v --show-ids --xml),
30 "--revision=revid:" . $self->revision, $proj_path]);
31 # See Bzr::History for why we do this.
32 0 local $XML::Simple::PREFERRED_PARSER = 'XML::Parser';
33 0 my $xs = XML::Simple->new(ForceArray => [qw(file directory)],
34 KeyAttr => []);
35 0 my $xml = $xs->xml_in($xml_string);
36 0 my $log = $xml->{log};
37 # The format of the XML changed in xmloutput Revision 17.
38 0 ▶ my $files = exists $log->{'affected-files'} ? $log->{'affected-files'}
Branch: 1 branch
BranchTrueFalseTotal
exists $log->{'affected-files'} ? : 0 0 0
39 : $log;
40 0 my (@added, @removed, @modified);
41 0 ▶ if (exists $files->{added}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $files->{"added"}) 0 0 0
42 0 @added = $self->_x_parse_items($files->{added}, $log);
43 }
44 0 ▶ if (exists $files->{removed}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $files->{"removed"}) 0 0 0
45 0 @removed = $self->_x_parse_items($files->{removed}, $log);
46 }
47 0 ▶ if (exists $files->{modified}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $files->{"modified"}) 0 0 0
48 0 @modified = $self->_x_parse_items($files->{modified}, $log);
49 }
50
51 0 my %moved;
52 0 ▶ if (exists $files->{renamed}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $files->{"renamed"}) 0 0 0
53 0 %moved = $self->_x_parse_renamed($files->{renamed}, $log);
54 }
55
56 return {
57 0 added => \@added,
58 removed => \@removed,
59 modified => \@modified,
60 moved => \%moved,
61 };
62 }
63  
64 0 ▶sub _x_parse_renamed {
Subroutine _x_parse_renamed: not called CC=5 SCAR=34.0
65 0 my ($self, $renamed, $log) = @_;
66 0 my %result;
67 0 ▶ foreach my $file (@{ $renamed->{file} || [] }) {
Condition0%0/2
$renamed->{'file'} || []
l!l
00
MC/DC0%0/1
$renamed->{'file'} || []
$renamed->{'file'}
Truth table0%0/2
A
A= $renamed->{'file'}
Aresult
11
00
68 $result{$file->{content}} = $self->file_class->new(
69 path => $file->{oldpath}, x_before => $log->{revisionid},
70 0 project => $self->project);
71 }
72 0 ▶ foreach my $dir (@{ $renamed->{directory} || [] }) {
Condition0%0/2
$renamed->{'directory'} || []
l!l
00
MC/DC0%0/1
$renamed->{'directory'} || []
$renamed->{'directory'}
Truth table0%0/2
A
A= $renamed->{'directory'}
Aresult
11
00
73 $result{$dir->{content}} = $self->directory_class->new(
74 path => $dir->{oldpath}, x_before => $log->{revisionid},
75 0 project => $self->project);
76 }
77 0 return %result;
78 }
79  
80 0 ▶sub _x_parse_items {
Subroutine _x_parse_items: not called CC=5 SCAR=34.0
81 0 my ($self, $items, $log) = @_;
82  
83 0 my @result;
84 0 ▶ if (exists $items->{file}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $items->{"file"}) 0 0 0
85 0 foreach my $file (@{ $items->{file} }) {
86 # Have to "require" to avoid dep loops.
87 push(@result, $self->file_class->new(
88 path => $file->{content}, revision => $log->{revisionid},
89 0 time => $log->{timestamp}, project => $self->project));
90 }
91 }
92 0 ▶ if (exists $items->{directory}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $items->{"directory"}) 0 0 0
93 0 foreach my $dir (@{ $items->{directory} }) {
94 0 require VCI::VCS::Bzr::Directory;
95 push(@result, $self->directory_class->new(
96 path => $dir->{content}, revision => $log->{revisionid},
97 0 time => $log->{timestamp}, project => $self->project));
98 }
99 }
100 0 return @result;
101 }
102  
103 1 __PACKAGE__->meta->make_immutable;
104  
105 1 1;
« VCI/VCS/Git/Directory.pm ↑ Summary VCI/VCS/Cvs/Directory.pm »