| 1 | # ABSTRACT: Join two stack histories together | ||||||||||
| 2 | |||||||||||
| 3 | package Pinto::Action::Merge; | ||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use MooseX::StrictConstructor; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use MooseX::Types::Moose qw(Bool); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use MooseX::MarkAsMethods ( autoclean => 1 ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Pinto::Util qw(throw); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Pinto::Types qw(StackName StackObject StackDefault); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | #------------------------------------------------------------------------------ | ||||||||||
| 14 | |||||||||||
| 15 | 1 | our $VERSION = '0.14'; # VERSION | |||||||||
| 16 | |||||||||||
| 17 | #------------------------------------------------------------------------------ | ||||||||||
| 18 | |||||||||||
| 19 | 1 | extends qw( Pinto::Action ); | |||||||||
| 20 | |||||||||||
| 21 | #------------------------------------------------------------------------------ | ||||||||||
| 22 | |||||||||||
| 23 | 1 | with qw( Pinto::Role::Transactional ); | |||||||||
| 24 | |||||||||||
| 25 | #------------------------------------------------------------------------------ | ||||||||||
| 26 | |||||||||||
| 27 | 1 | has stack => ( | |||||||||
| 28 | is => 'ro', | ||||||||||
| 29 | isa => StackName | StackObject, | ||||||||||
| 30 | required => 1, | ||||||||||
| 31 | ); | ||||||||||
| 32 | |||||||||||
| 33 | |||||||||||
| 34 | 1 | has into_stack => ( | |||||||||
| 35 | is => 'ro', | ||||||||||
| 36 | isa => StackName | StackObject | StackDefault, | ||||||||||
| 37 | default => undef, | ||||||||||
| 38 | ); | ||||||||||
| 39 | |||||||||||
| 40 | #------------------------------------------------------------------------------ | ||||||||||
| 41 | |||||||||||
| 42 | 0 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: not called CC=3 SCAR=24.8
| |||||||||||
| 43 | 0 | my ($self) = @_; | |||||||||
| 44 | |||||||||||
| 45 | 0 | my $stack = $self->repo->get_stack($self->stack); | |||||||||
| 46 | 0 | my $from_head = $stack->head; | |||||||||
| 47 | |||||||||||
| 48 | 0 | my $into_stack = $self->repo->get_stack($self->into_stack); | |||||||||
| 49 | 0 | my $into_head = $into_stack->head; | |||||||||
| 50 | |||||||||||
| 51 | 0 | ▶ | return 1 && $self->warning("Both stacks are the same ($into_head)") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | if $into_head->id == $from_head->id; | ||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | throw "Recursive merge is not supported yet" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | unless $from_head->is_descendant_of($into_head); | ||||||||||
| 56 | |||||||||||
| 57 | 0 | $into_stack->update({head => $from_head->id}); | |||||||||
| 58 | 0 | $into_stack->write_index; | |||||||||
| 59 | |||||||||||
| 60 | 0 | my $format = '%i: %{40}T'; | |||||||||
| 61 | 0 | $self->diag("Fast-forward..."); | |||||||||
| 62 | 0 | $self->diag("Stack $into_stack was " . $into_head->to_string($format)); | |||||||||
| 63 | 0 | $self->diag("Stack $into_stack now " . $from_head->to_string($format)); | |||||||||
| 64 | |||||||||||
| 65 | 0 | return 1; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | #------------------------------------------------------------------------------ | ||||||||||
| 69 | |||||||||||
| 70 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 71 | |||||||||||
| 72 | #------------------------------------------------------------------------------ | ||||||||||
| 73 | |||||||||||
| 74 | 1 | 1; | |||||||||
| 75 | |||||||||||
| 76 | __END__ | ||||||||||