| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 62 | 0 | ▶ | return $commit if $commits[0]->revision eq $self->x_before; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | } | ||||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 0 | return $self->last_revision; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 70 | |||||||||||
| 71 | 1 | 1; | |||||||||