VCI/VCS/Bzr/Committable.pm

filter: Statementstmt 17.1% 6 / 35 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 20.0% 1 / 5 Podpod n/a totaltotal 13.4% 7 / 52 CC 7 SCAR 27.8
CC
7
Cov
13%
_x_this_commit
30.0
_build_time
6.0
_build_revision
6.0
CRAP 16.1
« VCI/VCS/Git/Commit.pm ↑ Summary VCI/VCS/Hg/Commit.pm »
1 package VCI::VCS::Bzr::Committable;
2 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 # When pulling moved files or directories out of logs, for the old file name,
5 # we know only the path of the old file and the revision where it was moved.
6 # So if the caller needs any other data, we will have to get it using this
7 # info.
8 1 has 'x_before' => (is => 'ro', isa => 'Str', predicate => 'has_x_before');
9  
10 0 ▶sub _build_time {
Subroutine _build_time: not called CC=2 SCAR=17.9
11 0 my $self = shift;
12 0 my $commit = $self->_x_this_commit;
13 # Since we've got it now, set the revision if it's not set.
14 0 ▶ if (!defined $self->{revision}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"revision"}) 0 0 0
15 0 $self->{revision} = $commit->revision;
16 }
17 0 return $commit->time;
18 }
19  
20 0 ▶sub _build_revision {
Subroutine _build_revision: not called CC=2 SCAR=17.9
21 0 my $self = shift;
22 0 my $commit = $self->_x_this_commit;
23 # Since we've got it now, set the time if it's not set.
24 0 ▶ if (!defined $self->{_time}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_time"}) 0 0 0
25 0 $self->{time} = $commit->time;
26 }
27 0 return $commit->revision;
28 }
29  
30 0 ▶sub _build_history {
Subroutine _build_history: not called CC=1 SCAR=6.9
31 0 my $self = shift;
32 0 my $full_path = $self->repository->root . $self->project->name
33 . '/' . $self->path->stringify;
34 0 my $xml_string = $self->vci->x_do(
35 args => [qw(log --show-ids --xml), $full_path]);
36 0 return $self->history_class->x_from_xml($xml_string, $self->project);
37 }
38  
39 0 ▶sub _x_this_commit {
Subroutine _x_this_commit: not called CC=5 SCAR=34.0
40 0 my $self = shift;
41  
42 0 ▶ if ($self->_has_revision) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_has_revision) 0 0 0
43 # XXX To optimize, could check ->history before going to bzr.
44 # However, I'm not aware of any situation where we already have
45 # a history but don't have a time/revision.
46  
47 0 my $vci = $self->vci;
48 0 my $obj_path = Path::Abstract::Underload->new($self->project->name, $self->path);
49 0 my $full_path = $self->repository->root . $obj_path->stringify;
50 0 my $rev = $self->revision;
51 0 my $log = $vci->x_do(args => [qw(log --xml --show-ids),
52 "--revision=revid:$rev", $full_path]);
53 0 my $hist = $self->history_class->x_from_xml($log, $self->project);
54 0 return $hist->commits->[0];
55 }
56  
57 0 ▶ if ($self->has_x_before) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_x_before) 0 0 0
58 0 my @commits = @{ $self->history->commits };
59 # We want to get the revision in this file's history right
60 # before x_before.
61 0 ▶ while (my $commit = shift @commits) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $commit = shift @commits) 0 0 0
62 0 ▶ return $commit if $commits[0]->revision eq $self->x_before;
Branch: 1 branch
BranchTrueFalseTotal
if $commits[0]->revision eq $self->x_before 0 0 0
63 }
64 }
65
66 0 return $self->last_revision;
67 }
68  
69 1 __PACKAGE__->meta->make_immutable;
70  
71 1 1;
« VCI/VCS/Git/Commit.pm ↑ Summary VCI/VCS/Hg/Commit.pm »