blib/lib/Pinto/Action/Reset.pm

filter: Statementstmt 68.4% 26 / 38 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 85.7% 6 / 7 Podpod n/a totaltotal 59.2% 32 / 54 CC 4 SCAR 21.5
CC
4
Cov
58%
execute
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 8.6
« blib/lib/App/Pinto/Command/roots.pm ↑ Summary blib/lib/Pinto/Action/Diff.pm »
1 # ABSTRACT: Reset stack to a prior revision
2  
3 package Pinto::Action::Reset;
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 StackDefault RevisionID);
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 | StackDefault,
30 default => undef,
31 );
32  
33 1 has revision => (
34 is => 'ro',
35 isa => RevisionID,
36 required => 1,
37 coerce => 1,
38 );
39  
40 1 has force => (
41 is => 'ro',
42 isa => Bool,
43 default => 0,
44 );
45  
46 #------------------------------------------------------------------------------
47  
48 0 ▶sub execute {
Subroutine execute: not called CC=4 SCAR=30.0
49 0 my ($self) = @_;
50  
51 0 my $rev = $self->repo->get_revision($self->revision);
52 0 my $stack = $self->repo->get_stack($self->stack);
53 0 my $head = $stack->head;
54  
55 0 ▶ throw "Revision $rev is the head of stack $stack"
Branch: 1 branch
BranchTrueFalseTotal
if $rev->id == $head->id 0 0 0
56 if $rev->id == $head->id;
57  
58 0 ▶ throw "Revision $rev is not an ancestor of stack $stack"
Branch: 1 branch
BranchTrueFalseTotal
unless $rev->is_ancestor_of($head) or $self->force 0 0 0
Condition0%0/3
$rev->is_ancestor_of($head) or $self->force
l!l&&r!l&&!r
000
MC/DC0%0/2
$rev->is_ancestor_of($head) or $self->force
$rev->is_ancestor_of($head) $self->force
Truth table0%0/3
A or B
A= $rev->is_ancestor_of($head)B= $self->force
ABresult
1X1
011
000
59 if !$rev->is_ancestor_of($head) && !$self->force;
60  
61 0 $stack->set_head($rev);
62 0 $stack->write_index;
63  
64 0 my $format = '%i: %{40}T';
65 0 $self->diag("Stack $stack was " . $head->to_string($format));
66 0 $self->diag("Stack $stack now " . $rev->to_string($format));
67  
68 0 return 1;
69 }
70  
71 #------------------------------------------------------------------------------
72  
73 1 __PACKAGE__->meta->make_immutable;
74  
75 #------------------------------------------------------------------------------
76  
77 1 1;
78  
79 __END__
« blib/lib/App/Pinto/Command/roots.pm ↑ Summary blib/lib/Pinto/Action/Diff.pm »