| 1 | package VCS::Lite::Shell; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = '0.11'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use vars qw (@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Exporter (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 2 | @ISA = qw (Exporter); | |||||||||||||||||||||||||||
| 14 | #Give a hoot don't pollute, do not export more than needed by default | ||||||||||||||||||||||||||||
| 15 | 2 | @EXPORT = qw (); | |||||||||||||||||||||||||||
| 16 | 2 | @EXPORT_OK = qw (store add remove list check_in check_out commit update fetch diff); | |||||||||||||||||||||||||||
| 17 | 2 | %EXPORT_TAGS = ( | |||||||||||||||||||||||||||
| 18 | local => [qw/store add remove check_in fetch diff/], | ||||||||||||||||||||||||||||
| 19 | all => [qw/store add remove list check_in fetch diff check_out commit update/] | ||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use Params::Validate qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use VCS::Lite::Repository; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use Cwd; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 2 | our %store_list; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | sub store { | ||||||||||||||||||||||||||||
| 31 | 1 | ▶ | my ($which, $type, @att) = @_; | ||||||||||||||||||||||||||
|
Subroutine
store: called CC=6 SCAR=19.3
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | ▶ | $which ||= 'current'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$which ||= "current"
MC/DC0%0/1
$which ||= "current"
$which
Truth table50%1/2
A
A= $which
| |||||||||||||||||||||||||||||
| 34 | 1 | ▶ | $type = 'VCS::Lite::Store::'.$type unless $type =~ /\:\:/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 1 | ▶ | if ($type =~ /^\w+(:?\:\:\w+)*$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 1 | eval "require $type"; | |||||||||||||||||||||||||||
| 37 | 1 | ▶ | carp $@ if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 1 | ▶ | $store_list{$which} = @att ? $type->new(@att) : $type; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | sub repository { | ||||||||||||||||||||||||||||
| 44 | 1 | ▶ | my ($store,$dir) = validate_pos( @_, | ||||||||||||||||||||||||||
|
Subroutine
repository: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | { type => SCALAR | OBJECT}, | ||||||||||||||||||||||||||||
| 46 | { type => SCALAR, default => '.'} ); | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | store($store, VCS::Lite::Repository->default_store) | ||||||||||||||||||||||||||||
| 49 | 1 | ▶ | unless exists $store_list{$store}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 1 | VCS::Lite::Repository->new( $dir, store=>$store_list{$store} ); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | sub member { | ||||||||||||||||||||||||||||
| 54 | 5 | ▶ | my ($st,$mem) = validate_pos( @_, | ||||||||||||||||||||||||||
|
Subroutine
member: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | { type => SCALAR | OBJECT}, | ||||||||||||||||||||||||||||
| 56 | { type => SCALAR, default => '.'} ); | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | store($st, VCS::Lite::Repository->default_store) | ||||||||||||||||||||||||||||
| 59 | 5 | ▶ | unless exists $store_list{$st}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 5 | $store_list{$st}->retrieve($mem); | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | sub add { | ||||||||||||||||||||||||||||
| 64 | 1 | ▶ | my $ele = shift; | ||||||||||||||||||||||||||
|
Subroutine
add: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 1 | repository('current')->add($ele); | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | sub remove { | ||||||||||||||||||||||||||||
| 70 | 0 | ▶ | my $ele = shift; | ||||||||||||||||||||||||||
|
Subroutine
remove: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | repository('current')->remove($ele); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | sub list { | ||||||||||||||||||||||||||||
| 76 | 0 | ▶ | my %par = validate(@_, { | ||||||||||||||||||||||||||
|
Subroutine
list: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 77 | recurse => 0} ); | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | repository('current')->traverse( 'name', %par); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | sub fetch { | ||||||||||||||||||||||||||||
| 83 | 0 | ▶ | my ($ele, $gen) = validate_pos( @_, {type => SCALAR}, 0); | ||||||||||||||||||||||||||
|
Subroutine
fetch: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | my $mem = member('current',$ele); | |||||||||||||||||||||||||||
| 86 | 0 | my %par = (); | |||||||||||||||||||||||||||
| 87 | 0 | ▶ | $par{generation} = $gen if defined $gen && $gen ne 'latest'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $gen and $gen ne "latest"
MC/DC0%0/2
defined $gen and $gen ne "latest"
defined $gen
$gen ne "latest"
Truth table0%0/3
A and B
A= defined $genB= $gen ne "latest"
| |||||||||||||||||||||||||||||
| 88 | 0 | $mem->fetch(%par)->text; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | sub diff { | ||||||||||||||||||||||||||||
| 92 | 3 | ▶ | my %par = validate( @_, | ||||||||||||||||||||||||||
|
Subroutine
diff: called CC=6 SCAR=19.4
Pod
documented
| |||||||||||||||||||||||||||||
| 93 | { | ||||||||||||||||||||||||||||
| 94 | file1 => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 95 | gen1 => { | ||||||||||||||||||||||||||||
| 96 | type => SCALAR, | ||||||||||||||||||||||||||||
| 97 | optional => 1, | ||||||||||||||||||||||||||||
| 98 | regex => qr/^\d+$/ | ||||||||||||||||||||||||||||
| 99 | }, | ||||||||||||||||||||||||||||
| 100 | file2 => { | ||||||||||||||||||||||||||||
| 101 | type => SCALAR, | ||||||||||||||||||||||||||||
| 102 | optional => 1, | ||||||||||||||||||||||||||||
| 103 | }, | ||||||||||||||||||||||||||||
| 104 | gen2 => { | ||||||||||||||||||||||||||||
| 105 | type => SCALAR, | ||||||||||||||||||||||||||||
| 106 | optional => 1, | ||||||||||||||||||||||||||||
| 107 | regex => qr/^\d+$|^latest$/ | ||||||||||||||||||||||||||||
| 108 | }, | ||||||||||||||||||||||||||||
| 109 | } ); | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | my $lite1 = member('current',$par{file1}) | ||||||||||||||||||||||||||||
| 112 | 3 | ▶ | ->fetch(exists($par{gen1}) ? (generation => $par{gen1}) : ()); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 3 | my $lite2; | |||||||||||||||||||||||||||
| 114 | 3 | ▶ | $par{file2} ||= $par{file1}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$par{"file2"} ||= $par{"file1"}
MC/DC0%0/2
$par{"file2"} ||= $par{"file1"}
$par{"file2"}
$par{"file1"}
Truth table33%1/3
A ||= B
A= $par{"file2"}B= $par{"file1"}
| |||||||||||||||||||||||||||||
| 115 | 3 | ▶ | if (exists $par{gen2}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | $lite2 = member('current',$par{file2}) | ||||||||||||||||||||||||||||
| 117 | 0 | ▶ | ->fetch(($par{gen1} eq 'latest') ? () : (generation => $par{gen2})); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | } else { | ||||||||||||||||||||||||||||
| 119 | 3 | $lite2 = VCS::Lite->new($par{file2}); | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 3 | ▶ | my $d = $lite1->delta($lite2) or return ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 2 | $d->udiff; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | sub check_out { | ||||||||||||||||||||||||||||
| 127 | 0 | ▶ | my $parent_path = shift; | ||||||||||||||||||||||||||
|
Subroutine
check_out: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | store('current', VCS::Lite::Repository->default_store) | ||||||||||||||||||||||||||||
| 130 | 0 | ▶ | unless exists $store_list{current}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | repository('parent',$parent_path) | ||||||||||||||||||||||||||||
| 133 | 0 | ->check_out( cwd(), store => $store_list{current} ); | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | sub check_in { | ||||||||||||||||||||||||||||
| 137 | 2 | ▶ | my ($what,$descr) = @_; | ||||||||||||||||||||||||||
|
Subroutine
check_in: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 2 | member('current',$what)->check_in( description => $descr); | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | sub commit { | ||||||||||||||||||||||||||||
| 143 | 0 | ▶ | repository('current')->commit(); | ||||||||||||||||||||||||||
|
Subroutine
commit: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | sub update { | ||||||||||||||||||||||||||||
| 147 | 0 | ▶ | repository('current')->update(); | ||||||||||||||||||||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 2 | 1; #this line is important and will help the module return a true value | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | __END__ | ||||||||||||||||||||||||||||