| 1 | package VCS::Lite::Repository; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 10 | our $VERSION = '0.11'; | |||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 10 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use File::Spec::Functions qw(:ALL !path); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 10 | ▶ | use Time::Piece; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 10 | ▶ | use VCS::Lite::Element; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 10 | ▶ | use Params::Validate qw(:all); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 10 | ▶ | use Cwd qw(abs_path); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 10 | ▶ | use base qw(VCS::Lite::Common); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 97 | ▶ | my $pkg = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=23.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 97 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | 97 | my %args = validate ( @_, | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | store => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | type => SCALAR | OBJECT, | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | default => $pkg->default_store | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | verbose => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 97 | my $verbose = $args{verbose}; | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 97 | ▶ | if (-d $path) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } elsif (-f $path) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | croak "Invalid path '$path' must be a directory"; | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 11 | ▶ | mkdir $path or croak "Failed to create directory: $!"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 95 | my $abspath = abs_path($path); | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | 95 | my $proto = bless { | |||||||||||||||||||||||||||||||||||||||||||||
| 45 | path => $abspath, | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | verbose => $verbose, | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | contents => [] | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | },$pkg; | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 95 | my $store_pkg; | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | 95 | ▶ | if (ref $args{store}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $store_pkg = $args{store}; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 95 | ▶ | $store_pkg = ($args{store} =~ /\:\:/) ? $args{store} : "VCS::Lite::Store::$args{store}"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 95 | eval "require $store_pkg"; | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | 95 | ▶ | warn "Failed to require $store_pkg\n$@" if $@; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 95 | my $repos = $store_pkg->retrieve_or_create($proto); | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | 95 | ▶ | if (exists $repos->{elements}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | $repos->_mumble("Upgrading repository $abspath from 0.02 to $VERSION"); | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | $repos->{contents} ||= $repos->{elements}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$repos->{"contents"} ||= $repos->{"elements"}
MC/DC0%0/2
$repos->{"contents"} ||= $repos->{"elements"}
$repos->{"contents"}
$repos->{"elements"}
Truth table0%0/3
A ||= B
A= $repos->{"contents"}B= $repos->{"elements"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | delete $repos->{elements}; | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $repos->save; | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 95 | $repos->path($abspath); | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | 95 | $repos->{author} = $repos->user; | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | 95 | $repos->{verbose} = $verbose; | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | 95 | $repos; | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | sub add { | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 13 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add: called CC=13 SCAR=25.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 13 | my ($file) = validate_pos(@_, { type => SCALAR }); | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 13 | my $path = $self->path; | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | 13 | my ($vol,$dirs,$fil) = splitpath($file); | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | 13 | my $absfile; | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | my $remainder; | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 13 | ▶ | if ($dirs) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | my ($top,@dirs) = splitdir($dirs); | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | ▶ | $top = shift @dirs if $top eq ''; # VMS quirk | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | ▶ | pop @dirs if !defined($dirs[-1]) || ($dirs[-1] eq ''); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $dirs[-1] or $dirs[-1] eq ""
MC/DC0%0/2
not defined $dirs[-1] or $dirs[-1] eq ""
not defined $dirs[-1]
$dirs[-1] eq ""
Truth table33%1/3
not(A) or B
A= not defined $dirs[-1]B= $dirs[-1] eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 2 | $absfile = abs_path(catfile($path,$top)); | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | ▶ | mkdir $absfile unless -d $absfile; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | ▶ | $remainder = @dirs ? catpath($vol,catdir(@dirs),$fil) : $fil; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | $file = $top; | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 11 | $absfile = catfile($path,$fil); | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 13 | ▶ | unless ((catdir($file) eq updir) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
catdir($file) eq ".." or catdir($file) eq "." or grep {$file eq $_;} @{$$self{"contents"};}
catdir($file) eq ".." or catdir($file) eq "."
MC/DC33%1/3
catdir($file) eq ".." or catdir($file) eq "." or grep {$file eq $_;} @{$$self{"contents"};}
catdir($file) eq ".."
catdir($file) eq "."
grep {$file eq $_;} @{$$self{"contents"};}
Truth table50%2/4
A or B or C
A= catdir($file) eq ".."B= catdir($file) eq "."C= grep {$file eq $_;} @{$$self{"contents"};}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | (catdir($file) eq curdir) || | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 10 | grep {$file eq $_} @{$self->{contents}}) { | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 12 | $self->_mumble("Add $file to $path"); | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 12 | my @newlist = sort(@{$self->{contents}},$file); | |||||||||||||||||||||||||||||||||||||||||||||
| 101 | 12 | ▶ | $self->{transactions} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"transactions"} ||= []
MC/DC100%1/1
$self->{"transactions"} ||= []
$self->{"transactions"}
Truth table100%2/2
A
A= $self->{"transactions"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 12 | my @trans = (@{$self->{transactions}}, ['add',$file]); | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | 12 | $self->_update_ctrl( contents => \@newlist, transactions => \@trans); | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | my $newobj = ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | -d $absfile) | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | ? VCS::Lite::Repository->new($absfile, store => $self->{store}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | : VCS::Lite::Element->new($absfile, store => $self->{store} | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 13 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 13 | ▶ | $remainder ? $newobj->add($remainder) : $newobj; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | sub add_element { | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | my ($self,$file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_element: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | ▶ | (-d $file) ? undef : add(@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | sub add_repository { | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 2 | ▶ | my ($self,$dir) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_repository: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | ▶ | return if -f $dir; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | mkdir catfile($self->{path},$dir); | |||||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | add(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | sub remove { | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | my ($file) = validate_pos(@_, { type => SCALAR }); | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | my @contents; | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | my $doit = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | for (@{$self->{contents}}) { | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 5 | ▶ | if ($file eq $_) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 2 | $doit++; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 3 | push @contents,$_; | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | ▶ | return unless $doit; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | $self->_mumble("Remove $file from " . $self->path); | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | ▶ | $self->{transactions} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"transactions"} ||= []
MC/DC100%1/1
$self->{"transactions"} ||= []
$self->{"transactions"}
Truth table100%2/2
A
A= $self->{"transactions"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 2 | my @trans = (@{$self->{transactions}}, ['remove',$file]); | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | $self->_update_ctrl( contents => \@contents, transactions => \@trans); | |||||||||||||||||||||||||||||||||||||||||||||
| 148 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | sub contents { | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 45 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
contents: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 105 | my $file = catfile($self->{path},$_); | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | (-d $file) | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | ? VCS::Lite::Repository->new($file, | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | verbose => $self->{verbose}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | store => $self->{store}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | : VCS::Lite::Element->new($file, | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | verbose => $self->{verbose}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 105 | ▶ | store => $self->{store}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 45 | } @{$self->{contents}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | sub elements { | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
elements: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | grep {$_->isa('VCS::Lite::Element')} $self->contents; | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | sub repositories { | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repositories: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | grep {$_->isa('VCS::Lite::Repository')} $self->contents; | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | sub traverse { | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 37 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
traverse: called CC=11 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 37 | my $func = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | 37 | my %args = validate(@_, | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | recurse => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | params => { type => ARRAYREF | SCALAR, optional => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 37 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | 37 | ▶ | $args{params} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"params"} ||= []
MC/DC100%1/1
$args{"params"} ||= []
$args{"params"}
Truth table100%2/2
A
A= $args{"params"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 37 | ▶ | $args{params} = [$args{params}] unless ref $args{params}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 37 | for ($self->contents) { | |||||||||||||||||||||||||||||||||||||||||||||
| 192 | 89 | ▶ | if ($args{recurse} && ($args{recurse} eq 'pre')) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args{"recurse"} and $args{"recurse"} eq "pre"
MC/DC0%0/2
$args{"recurse"} and $args{"recurse"} eq "pre"
$args{"recurse"}
$args{"recurse"} eq "pre"
Truth table66%2/3
A and B
A= $args{"recurse"}B= $args{"recurse"} eq "pre"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my @subout = grep {defined $_} $_->traverse($func,%args); | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | push @out,\@subout if @subout; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 97 | ▶ | my @res = grep {defined $_} ((ref $func) ? | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 15 | &$func($_,@{$args{params}}) : | |||||||||||||||||||||||||||||||||||||||||||||
| 198 | 89 | $_->$func(@{$args{params}})); | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | 89 | push @out,@res; | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | 89 | ▶ | if ($args{recurse} && ($args{recurse} ne 'pre')) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args{"recurse"} and $args{"recurse"} ne "pre"
MC/DC50%1/2
$args{"recurse"} and $args{"recurse"} ne "pre"
$args{"recurse"}
$args{"recurse"} ne "pre"
Truth table66%2/3
A and B
A= $args{"recurse"}B= $args{"recurse"} ne "pre"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 20 | my @subout = grep {defined $_} $_->traverse($func,%args); | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | 20 | ▶ | push @out,\@subout if @subout; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 37 | @out; | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | sub check_out { | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 9 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_out: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 9 | my $newpath = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 211 | 9 | my %args = validate(@_, | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | store => { type => SCALAR|OBJECT, optional => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 9 | $self->_mumble("Check out " . $self->path . " to $newpath"); | |||||||||||||||||||||||||||||||||||||||||||||
| 217 | # $self->{transactions} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | my $newrep = VCS::Lite::Repository->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 219 | $newpath, | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | verbose => $self->{verbose}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 9 | %args); | |||||||||||||||||||||||||||||||||||||||||||||
| 222 | $newrep->_update_ctrl( | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | parent => $self->{path}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | contents => $self->{contents}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | original_contents => $self->{contents}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | parent_baseline => $self->latest, | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | parent_store => $self->{store} | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 9 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | 9 | $self->traverse('_check_out_member', params => [$newpath,%args]); | |||||||||||||||||||||||||||||||||||||||||||||
| 230 | VCS::Lite::Repository->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | $newpath, | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | verbose => $self->{verbose}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 9 | %args); | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | # This is different from the $newrep object, as it is fully populated. | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | sub check_in { | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 12 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_in: called CC=8 SCAR=21.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 12 | my %args = validate ( @_, | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | check_in_anyway => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | description => { type => SCALAR }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 12 | $self->_mumble("Checking in " . $self->path); | |||||||||||||||||||||||||||||||||||||||||||||
| 246 | 12 | ▶ | if (($self->{transactions} && @{$self->{transactions}}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$self->{"transactions"} and @{$self->{"transactions"};} or $args{"check_in_anyway"}
$self->{"transactions"} and @{$self->{"transactions"};}
MC/DC33%1/3
$self->{"transactions"} and @{$self->{"transactions"};} or $args{"check_in_anyway"}
$self->{"transactions"}
@{$self->{"transactions"};}
$args{"check_in_anyway"}
Truth table40%2/5
A and B or C
A= $self->{"transactions"}B= @{$self->{"transactions"};}C= $args{"check_in_anyway"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 247 | || $args{check_in_anyway}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 6 | $self->_mumble("Updating directory changes"); | |||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 6 | ▶ | my $newgen = $args{generation} || $self->latest; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args{'generation'} || $self->latest
MC/DC0%0/2
$args{'generation'} || $self->latest
$args{'generation'}
$self->latest
Truth table33%1/3
A || B
A= $args{'generation'}B= $self->latest
| |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 6 | $newgen =~ s/(\d+)$/$1+1/e; | |||||||||||||||||||||||||||||||||||||||||||||
| 253 | 6 | ▶ | $self->{generation} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"generation"} ||= {}
MC/DC0%0/1
$self->{"generation"} ||= {}
$self->{"generation"}
Truth table50%1/2
A
A= $self->{"generation"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 6 | my %gen = %{$self->{generation}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 255 | $gen{$newgen} = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | author => $self->user, | ||||||||||||||||||||||||||||||||||||||||||||||
| 257 | description => $args{description}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 258 | updated => localtime->datetime, | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | transactions => $self->{transactions}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | contents => $self->{contents}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 6 | ▶ | $self->{latest} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"latest"} ||= {}
MC/DC0%0/1
$self->{"latest"} ||= {}
$self->{"latest"}
Truth table50%1/2
A
A= $self->{"latest"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 6 | my %lat = %{$self->{latest}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 265 | 6 | $newgen =~ /(\d+\.)*\d+$/; | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | 6 | ▶ | my $base = $1 || ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$1 || ''
MC/DC0%0/1
$1 || ''
$1
Truth table50%1/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 6 | $lat{$base}=$newgen; | |||||||||||||||||||||||||||||||||||||||||||||
| 268 | 6 | delete $self->{transactions}; | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 6 | $self->_update_ctrl( generation => \%gen, latest => \%lat); | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 12 | $self->traverse('check_in', params => [%args]); | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | sub commit { | ||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 2 | ▶ | my ($self,$parent) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
commit: called CC=4 SCAR=15.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 2 | my $path = $self->path; | |||||||||||||||||||||||||||||||||||||||||||||
| 280 | 2 | my $repos_name = (splitdir($self->path))[-1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 281 | 2 | ▶ | my $parent_repos_path = $self->{parent} || catdir($parent,$repos_name); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'parent'} || catdir($parent, $repos_name)
MC/DC0%0/2
$self->{'parent'} || catdir($parent, $repos_name)
$self->{'parent'}
catdir($parent, $repos_name)
Truth table33%1/3
A || B
A= $self->{'parent'}B= catdir($parent, $repos_name)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 2 | $self->_mumble("Committing $path to $parent_repos_path"); | |||||||||||||||||||||||||||||||||||||||||||||
| 283 | my $parent_repos = VCS::Lite::Repository->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 284 | $parent_repos_path, | ||||||||||||||||||||||||||||||||||||||||||||||
| 285 | verbose => $self->{verbose}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 2 | ▶ | store => $self->{parent_store} || $self->{store}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'parent_store'} || $self->{'store'}
MC/DC0%0/2
$self->{'parent_store'} || $self->{'store'}
$self->{'parent_store'}
$self->{'store'}
Truth table33%1/3
A || B
A= $self->{'parent_store'}B= $self->{'store'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 2 | my $orig = VCS::Lite->new($repos_name,undef,$parent_repos->{contents}); | |||||||||||||||||||||||||||||||||||||||||||||
| 289 | 2 | my $changed = VCS::Lite->new($repos_name,undef,$self->{contents}); | |||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 2 | $self->_apply($parent_repos,$orig->delta($changed)); | |||||||||||||||||||||||||||||||||||||||||||||
| 292 | $self->traverse('commit', | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 2 | ▶ | params => $self->{parent} || catdir($parent,$repos_name)); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'parent'} || catdir($parent, $repos_name)
MC/DC0%0/2
$self->{'parent'} || catdir($parent, $repos_name)
$self->{'parent'}
catdir($parent, $repos_name)
Truth table33%1/3
A || B
A= $self->{'parent'}B= catdir($parent, $repos_name)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||
| 296 | sub update { | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 5 | ▶ | my ($self,$srep) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 5 | my $file = $self->path; | |||||||||||||||||||||||||||||||||||||||||||||
| 300 | 5 | my $repos_name = (splitdir($file))[-1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 301 | 5 | ▶ | $self->{parent} ||= catdir($srep,$repos_name); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"parent"} ||= catdir($srep, $repos_name)
MC/DC0%0/2
$self->{"parent"} ||= catdir($srep, $repos_name)
$self->{"parent"}
catdir($srep, $repos_name)
Truth table33%1/3
A ||= B
A= $self->{"parent"}B= catdir($srep, $repos_name)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 5 | my $parent = $self->{parent}; | |||||||||||||||||||||||||||||||||||||||||||||
| 303 | 5 | $self->_mumble("Updating $file from $parent"); | |||||||||||||||||||||||||||||||||||||||||||||
| 304 | 5 | ▶ | my $baseline = $self->{baseline} || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'baseline'} || 0
MC/DC0%0/1
$self->{'baseline'} || 0
$self->{'baseline'}
Truth table50%1/2
A
A= $self->{'baseline'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 5 | my $parbas = $self->{parent_baseline}; | |||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 5 | my $orig = $self->fetch( generation => $baseline); | |||||||||||||||||||||||||||||||||||||||||||||
| 308 | my $parele = VCS::Lite::Repository->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 309 | $parent, | ||||||||||||||||||||||||||||||||||||||||||||||
| 310 | verbose => $self->{verbose}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 5 | store => $self->{parent_store}); | |||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 5 | my $parfrom = $parele->fetch( generation => $parbas); | |||||||||||||||||||||||||||||||||||||||||||||
| 314 | 5 | my $parlat = $parele->latest; # was latest($parbas) - buggy | |||||||||||||||||||||||||||||||||||||||||||||
| 315 | 5 | my $parto = $parele->fetch( generation => $parlat); | |||||||||||||||||||||||||||||||||||||||||||||
| 316 | 5 | my $origplus = $parfrom->merge($parto,$orig); | |||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 5 | my $chg = VCS::Lite->new($repos_name,undef,$self->{contents}); | |||||||||||||||||||||||||||||||||||||||||||||
| 319 | 5 | my $merged = $orig->merge($origplus,$chg); | |||||||||||||||||||||||||||||||||||||||||||||
| 320 | 5 | $parele->_apply($self,$chg->delta($merged)); | |||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 5 | $self->_update_ctrl(baseline => $self->latest, parent_baseline => $parlat); | |||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 5 | $self->traverse('update', params => $parent); | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||
| 327 | sub fetch { | ||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 17 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch: called CC=16 SCAR=40.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 17 | my %args = validate ( @_, | |||||||||||||||||||||||||||||||||||||||||||||
| 330 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | time => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | generation => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 17 | ▶ | my $gen = exists($args{generation}) ? $args{generation} : $self->latest; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 17 | ▶ | if ($args{time}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my $latest_time = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | my $branch = $args{generation} || ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'generation'} || ''
MC/DC0%0/1
$args{'generation'} || ''
$args{'generation'}
Truth table0%0/2
A
A= $args{'generation'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | $branch .= '.' if $branch; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | for (keys %{$self->{generation}}) { | |||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | next unless /^$branch\d+$/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | next if $self->{generation}{$_}{updated} > $args{time}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 345 | ($latest_time,$gen) = ($self->{generation}{$_}{updated}, $_) | ||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | if $self->{generation}{$_}{updated} > $latest_time; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | return unless $latest_time; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 17 | ▶ | return if $gen && $self->{generation} && !$self->{generation}{$gen}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$gen and $self->{"generation"} and not $self->{"generation"}{$gen}
$gen and $self->{"generation"}
MC/DC0%0/3
$gen and $self->{"generation"} and not $self->{"generation"}{$gen}
$gen
$self->{"generation"}
not $self->{"generation"}{$gen}
Truth table50%2/4
A and B and not(C)
A= $genB= $self->{"generation"}C= not $self->{"generation"}{$gen}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||
| 354 | my $cont = | ||||||||||||||||||||||||||||||||||||||||||||||
| 355 | $gen | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | ? $self->{generation}{$gen}{contents} | ||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 17 | ▶ | : $self->{original_contents} || []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->{"original_contents"} or []
MC/DC0%0/1
$self->{"original_contents"} or []
$self->{"original_contents"}
Truth table50%1/2
A
A= $self->{"original_contents"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 17 | my $file = $self->{path}; | |||||||||||||||||||||||||||||||||||||||||||||
| 360 | 17 | ▶ | $gen ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$gen ||= 0
MC/DC100%1/1
$gen ||= 0
$gen
Truth table100%2/2
A
A= $gen
| |||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 17 | VCS::Lite->new("$file\@\@$gen",undef,$cont); | |||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | sub _apply { | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 7 | ▶ | my ($src,$dest,$delt) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply: called CC=11 SCAR=46.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 7 | ▶ | return unless $delt; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my $srcpath = $src->path; | |||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my $path = $dest->path; | |||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | for (map {@$_} $delt->hunks) { | |||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my ($ind,$lin,$val) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | if ($ind eq '-') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $dest->remove($val); | |||||||||||||||||||||||||||||||||||||||||||||
| 376 | } elsif ($ind eq '+') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my $destname = catdir($path,$val); | |||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my $srcname = catdir($srcpath,$val); | |||||||||||||||||||||||||||||||||||||||||||||
| 379 | # $srcname is false if catdir can't construct a dir, e.g. | ||||||||||||||||||||||||||||||||||||||||||||||
| 380 | # if on VMS and $val contains a dot | ||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | mkdir $destname if $srcname && -d $srcname; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$srcname and -d $srcname
MC/DC0%0/2
$srcname and -d $srcname
$srcname
-d $srcname
Truth table0%0/3
A and B
A= $srcnameB= -d $srcname
| |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | my $newobj = $dest->add($val); | |||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | if (exists($dest->{parent}) && ($dest->{parent} eq $srcpath)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $dest->{"parent"} and $dest->{"parent"} eq $srcpath
MC/DC0%0/2
exists $dest->{"parent"} and $dest->{"parent"} eq $srcpath
exists $dest->{"parent"}
$dest->{"parent"} eq $srcpath
Truth table0%0/3
A and B
A= exists $dest->{"parent"}B= $dest->{"parent"} eq $srcpath
| |||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | $newobj->{parent} = catdir($dest->{parent},$val); | |||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | $newobj->{parent_store} = $dest->{parent_store}; | |||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $newobj->{parent_baseline} = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $newobj->save; | |||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | if (exists($src->{parent}) && ($src->{parent} eq $path)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $src->{"parent"} and $src->{"parent"} eq $path
MC/DC0%0/2
exists $src->{"parent"} and $src->{"parent"} eq $path
exists $src->{"parent"}
$src->{"parent"} eq $path
Truth table0%0/3
A and B
A= exists $src->{"parent"}B= $src->{"parent"} eq $path
| |||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | my $srcobj = $src->{store}->retrieve($srcname); | |||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $srcobj->{parent} = catdir($src->{parent},$val); | |||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | $srcobj->{parent_store} = $src->{parent_store}; | |||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | $srcobj->{parent_baseline} = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $srcobj->save; | |||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | sub _check_out_member { | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_out_member: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 5 | my $newpath = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 403 | 5 | my %args = validate(@_, | |||||||||||||||||||||||||||||||||||||||||||||
| 404 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 405 | store => { type => SCALAR|OBJECT, optional => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 5 | my $repos_name = (splitdir($self->path))[-1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 409 | my $newrep = VCS::Lite::Repository->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 410 | $newpath, | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | verbose => $self->{verbose}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 5 | %args); | |||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 5 | my $new_repos = catdir($newpath,$repos_name); | |||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 5 | $self->check_out($new_repos,%args); | |||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||
| 419 | sub _update_ctrl { | ||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 34 | ▶ | my ($self,%args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_ctrl: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 34 | ▶ | my $path = $args{path} || $self->{path}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args{'path'} || $self->{'path'}
MC/DC0%0/2
$args{'path'} || $self->{'path'}
$args{'path'}
$self->{'path'}
Truth table33%1/3
A || B
A= $args{'path'}B= $self->{'path'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 34 | for (keys %args) { | |||||||||||||||||||||||||||||||||||||||||||||
| 424 | 95 | $self->{$_} = $args{$_}; | |||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 34 | $self->{updated} = localtime->datetime; | |||||||||||||||||||||||||||||||||||||||||||||
| 428 | 34 | $self->save; | |||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||
| 433 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||