| 1 | package VCS::Lite; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 9 | our $VERSION = '0.12'; | |||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | VCS::Lite - Minimal version control system | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | use VCS::Lite; | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # diff | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | my $lit = VCS::Lite->new('/home/me/foo1.txt'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | my $lit2 = VCS::Lite->new('/home/me/foo2.txt'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | my $difftxt = $lit->delta($lit2)->diff; | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | print OUTFILE $difftxt; | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # patch | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | my $delt = VCS::Lite::Delta->new('/home/me/patch.diff'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | my $lit3 = $lit->patch($delt); | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | print OUTFILE $lit3->text; | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # merge | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | my $lit4 = $lit->merge($lit->delta($lit2),$lit->delta($lit3)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | print OUTFILE $lit4->text; | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | This module provides the functions normally associated with a version | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | control system, but without needing or implementing a version control | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | system. Applications include wikis, document management systems and | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | configuration management. | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | It makes use of the module Algorithm::Diff. It provides the facility | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | for basic diffing, patching and merging. | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ############################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | #Library Modules # | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ############################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 9 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 9 | ▶ | use Algorithm::Diff qw(traverse_sequences); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 9 | ▶ | use VCS::Lite::Delta; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ############################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | #Interface Methods # | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ############################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 37 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=18 SCAR=32.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 37 | my ($class,$id,$sep,$src,@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 37 | my %proto = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # Decode $sep as needed | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 37 | ▶ | if (ref($sep) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 10 | %proto = %$sep; | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | 10 | $sep = $proto{in}; | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | 10 | delete $proto{in}; | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # DWIM logic, based on $src parameter. | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # Case 0: $src missing. Use $id as file name, becomes case 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 37 | ▶ | open $src,$id or croak("failed to open '$id': $!") unless $src; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$src || (open($src, $id) || croak("failed to open '${id}': $!"))
open $src, $id or croak("failed to open '${id}': $!")
MC/DC0%0/2
$src || (open($src, $id) || croak("failed to open '${id}': $!"))
$src
open $src, $id
Truth table66%2/3
A || B
A= $srcB= open $src, $id
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 37 | my $atyp = ref $src; | |||||||||||||||||||||||||||||||||||||||||||||
| 82 | 37 | ▶ | $sep ||= $/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$sep ||= $/
MC/DC0%0/2
$sep ||= $/
$sep
$/
Truth table66%2/3
A ||= B
A= $sepB= $/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 37 | ▶ | local $/ = $sep if $sep; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 37 | ▶ | $proto{out} ||= $\ || ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
$proto{"out"} ||= $\ || ""
$\ || ''
MC/DC50%1/2
$proto{"out"} ||= $\ || ""
$proto{"out"}
$\
Truth table66%2/3
A ||= B
A= $proto{"out"}B= $\
| |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 37 | my $out_sep = $proto{out}; | |||||||||||||||||||||||||||||||||||||||||||||
| 86 | 37 | my @contents; | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # Case 1: $src is string | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 37 | ▶ | if (!$atyp) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | @contents = split /(?=$sep)/,$src; | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # Case 2: $src is arrayref | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | elsif ($atyp eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 17 | @contents = @$src; | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # Case 3: $src is globref (file handle) | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | elsif ($atyp eq 'GLOB') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 20 | @contents = <$src>; | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # Case 4: $src is coderef - callback | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | elsif ($atyp eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | while (my $item=&$src(@args)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | push @contents,$item; | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # Case otherwise is an error. | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | croak "Invalid argument"; | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 37 | ▶ | $proto{last_line_short} = 1 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@contents and not $contents[-1] =~ /$sep$/
MC/DC50%1/2
@contents and not $contents[-1] =~ /$sep$/
@contents
not $contents[-1] =~ /$sep$/
Truth table66%2/3
A and not(B)
A= @contentsB= not $contents[-1] =~ /$sep$/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | if @contents && ($contents[-1] !~ /$sep$/); | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 37 | ▶ | if ($proto{chomp}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 6 | s/$sep$//s for @contents; | |||||||||||||||||||||||||||||||||||||||||||||
| 116 | 6 | ▶ | $proto{out} ||= $sep; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$proto{"out"} ||= $sep
MC/DC0%0/2
$proto{"out"} ||= $sep
$proto{"out"}
$sep
Truth table66%2/3
A ||= B
A= $proto{"out"}B= $sep
| |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 37 | bless { id => $id, | |||||||||||||||||||||||||||||||||||||||||||||
| 120 | contents => \@contents, | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | separator => $sep, | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | %proto },$class; | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | ▶ | sub original { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
original: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 2 | my $pkg = ref $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | exists($self->{original}) ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | bless ({ id => $self->id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | contents => $self->{original}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | separator => $self->{separator}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | out => $self->{out}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | chomp => $self->{chomp}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 2 | ▶ | }, $pkg ) : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | $self; | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 3 | ▶ | sub apply { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 3 | my ($self,$other,%par) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 3 | my $pkg = ref $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | 3 | my $base = $par{base}; | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | 3 | ▶ | $base ||= 'contents'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$base ||= "contents"
MC/DC100%1/1
$base ||= "contents"
$base
Truth table100%2/2
A
A= $base
| |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | $base = $pkg->new( $self->id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | $self->{separator}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 3 | ▶ | $self->{$base}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | unless ref $base; | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 3 | ▶ | my $cbase = exists($other->{original}) ? $other->original : $base; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 3 | my $mrg = $cbase->merge($base,$other); | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | 3 | my $mrg2 = $base->merge($self,$mrg); | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | 3 | ▶ | $self->{original} ||= $self->{contents}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"original"} ||= $self->{"contents"}
MC/DC0%0/2
$self->{"original"} ||= $self->{"contents"}
$self->{"original"}
$self->{"contents"}
Truth table66%2/3
A ||= B
A= $self->{"original"}B= $self->{"contents"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 3 | $self->{contents} = [$mrg2->text]; | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 40 | ▶ | sub text { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
text: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 40 | my ($self,$sep) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 40 | ▶ | $sep ||= $self->{out} || ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
$sep ||= $self->{"out"} || ""
$self->{'out'} || ''
MC/DC50%1/2
$sep ||= $self->{"out"} || ""
$sep
$self->{'out'}
Truth table66%2/3
A ||= B
A= $sepB= $self->{'out'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 40 | ▶ | wantarray ? @{$self->{contents}} : join $sep,@{$self->{contents}}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 26 | ▶ | sub id { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 26 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 26 | ▶ | @_ ? ($self->{id} = shift) : $self->{id}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 9 | ▶ | sub delta { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delta: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 9 | my $lite1 = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | 9 | my $lite2 = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 174 | 9 | my %par = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 9 | my @wl1 = $lite1->_window($par{window}); | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | 9 | my @wl2 = $lite2->_window($par{window}); | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | 29 | my @d = map { [map { [$_->[0] . ($_->[2]{short} ? '/' : ''), | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | 175 | ▶ | $_->[1], $_->[2]{line} ] } @$_ ] } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1627 | ▶ | Algorithm::Diff::diff(\@wl1,\@wl2,sub { $_[0]{window}; }) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 9 | ▶ | or return undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 7 | VCS::Lite::Delta->new(\@d,$lite1->id,$lite2->id,$lite1->{out}); | |||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 18 | ▶ | sub _window { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_window: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 18 | ▶ | my $win = shift || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 18 | ▶ | my ($win_from,$win_to) = ref($win) ? (-$win->[0],$win->[1]) : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | (-$win,$win); | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 18 | my @wintxt; | |||||||||||||||||||||||||||||||||||||||||||||
| 193 | 18 | my $max = $#{$self->{contents}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | 18 | for (0..$max) { | |||||||||||||||||||||||||||||||||||||||||||||
| 195 | 1599 | my $win_lb = $_ + $win_from; | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | 1599 | ▶ | $win_lb = 0 if $win_lb < 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1599 | my $win_ub = $_ + $win_to; | |||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1599 | ▶ | $win_ub = $max if $win_ub > $max; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | push @wintxt, join $self->{out}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 1599 | ▶ | (@{$self->{contents}}[$win_lb .. $win_ub], | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$win_ub < $max or not $self->{"last_line_short"}
MC/DC100%2/2
$win_ub < $max or not $self->{"last_line_short"}
$win_ub < $max
not $self->{"last_line_short"}
Truth table100%3/3
A or not(B)
A= $win_ub < $maxB= not $self->{"last_line_short"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1599 | (($win_ub < $max) || !$self->{last_line_short}) ? | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | '' : ()); | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 18 | map { {line => $self->{contents}[$_], | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | window => $wintxt[$_], | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1599 | ▶ | ( $self->{last_line_short} && ($_ == $max)) ? ( short => 1 ) : (), | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"last_line_short"} and $_ == $max
MC/DC100%2/2
$self->{"last_line_short"} and $_ == $max
$self->{"last_line_short"}
$_ == $max
Truth table100%3/3
A and B
A= $self->{"last_line_short"}B= $_ == $max
| |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } } | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | (0..$max); | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | ▶ | sub diff { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diff: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | $self->delta(@_)->diff; | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 6 | ▶ | sub patch { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
patch: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | 6 | my $patch = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | 6 | ▶ | $patch = VCS::Lite::Delta->new($patch,@_) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | unless ref $patch eq 'VCS::Lite::Delta'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 6 | my @out = @{$self->{contents}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 224 | 6 | my $id = $self->id; | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | 6 | my $pkg = ref $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | 6 | my @pat = $patch->hunks; | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 6 | for (@pat) { | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | 20 | for (@$_) { | |||||||||||||||||||||||||||||||||||||||||||||
| 230 | 148 | my ($ind,$lin,$txt) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||
| 231 | 148 | ▶ | next unless $ind =~ /^-/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 82 | ▶ | _error($lin,'Patch failed'),return undef | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | if $out[$lin] ne $txt; | ||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 6 | my $line_offset = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 238 | 6 | my $lls = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 6 | for (@pat) { | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | 20 | my @txt1 = grep {$_->[0] =~ /^\-/} @$_; | |||||||||||||||||||||||||||||||||||||||||||||
| 242 | 20 | my @txt2 = grep {$_->[0] =~ /^\+/} @$_; | |||||||||||||||||||||||||||||||||||||||||||||
| 243 | 20 | ▶ | my $base_line = @txt2 ? $txt2[0][1] : $txt1[0][1] + $line_offset; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 20 | splice @out,$base_line,scalar(@txt1),map {$_->[2]} @txt2; | |||||||||||||||||||||||||||||||||||||||||||||
| 245 | 20 | $line_offset += @txt2 - @txt1; | |||||||||||||||||||||||||||||||||||||||||||||
| 246 | 20 | $lls += grep {$_->[0] eq '+/'} @txt2; | |||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | $pkg->new($id,{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | in => $self->{separator}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | chomp => $self->{chomp}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | out => $self->{out}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 6 | last_line_short => $lls, | |||||||||||||||||||||||||||||||||||||||||||||
| 254 | },\@out); | ||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # Equality of two array references (contents) | ||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | sub _equal { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_equal: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my ($a,$b) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | return 0 if @$a != @$b; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | foreach (0..$#$a) { | |||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | return 0 if $a->[$_] ne $b->[$_]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 8 | ▶ | sub merge { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge: called CC=30 SCAR=36.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 8 | my ($self,$d1,$d2) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 273 | 8 | my $pkg = ref $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 8 | my $orig = [$self->text]; | |||||||||||||||||||||||||||||||||||||||||||||
| 276 | 8 | my $chg1 = [$d1->text]; | |||||||||||||||||||||||||||||||||||||||||||||
| 277 | 8 | my $chg2 = [$d2->text]; | |||||||||||||||||||||||||||||||||||||||||||||
| 278 | 8 | my $out_title = $d1->{id} . '|' . $d2->{id}; | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | 8 | my %ins1; | |||||||||||||||||||||||||||||||||||||||||||||
| 280 | 8 | my $del1 = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||
| 282 | traverse_sequences( $self->{contents}, $chg1, { | ||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 784 | ▶ | MATCH => sub { $del1 .= ' ' }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 24 | ▶ | DISCARD_A => sub { $del1 .= '-' }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 12 | ▶ | DISCARD_B => sub { push @{$ins1{$_[0]}},$chg1->[$_[1]] }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 8 | } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 8 | my %ins2; | |||||||||||||||||||||||||||||||||||||||||||||
| 289 | 8 | my $del2 = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | traverse_sequences( $self->{contents}, $chg2, { | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 749 | ▶ | MATCH => sub { $del2 .= ' ' }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 59 | ▶ | DISCARD_A => sub { $del2 .= '-' }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 66 | ▶ | DISCARD_B => sub { push @{$ins2{$_[0]}},$chg2->[$_[1]] }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 8 | } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # First pass conflict detection: deletion on file 1 and insertion on file 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 8 | $del1 =~ s(\-+){ | |||||||||||||||||||||||||||||||||||||||||||||
| 300 | 9 | my $stlin = length $`; | |||||||||||||||||||||||||||||||||||||||||||||
| 301 | 9 | my $numdel = length $&; | |||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 9 | ▶ | my @confl = map {exists $ins2{$_} ? ($_) : ()} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 304 | ($stlin+1..$stlin+$numdel-1); | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 9 | ▶ | @confl ? '*' x $numdel : $&; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | }eg; | ||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||
| 308 | # Now the other way round: deletion on file 2 and insertion on file 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 8 | $del2 =~ s(\-+){ | |||||||||||||||||||||||||||||||||||||||||||||
| 311 | 38 | my $stlin = length $`; | |||||||||||||||||||||||||||||||||||||||||||||
| 312 | 38 | my $numdel = length $&; | |||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 38 | ▶ | my @confl = map {exists $ins1{$_} ? ($_) : ()} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 315 | ($stlin+1..$stlin+$numdel-1); | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 38 | ▶ | @confl ? '*' x $numdel : $&; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 317 | }eg; | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||
| 319 | # Conflict type 1 is insert of 2 into deleted 1, Conflict type 2 is insert of 1 into deleted 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 320 | # @defer is used to hold the 'other half' alternative for the conflict | ||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 8 | my $conflict = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 323 | 8 | my $conflict_type = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 324 | 8 | my @defer; | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||
| 326 | my @out; | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 8 | for (0..@{$self->{contents}}) { | |||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # Get details pertaining to current @f0 input line | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 816 | my $line = $self->{contents}[$_]; | |||||||||||||||||||||||||||||||||||||||||||||
| 332 | 816 | my $d1 = substr $del1,$_,1; | |||||||||||||||||||||||||||||||||||||||||||||
| 333 | 816 | ▶ | my $ins1 = $ins1{$_} if exists $ins1{$_}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 816 | my $d2 = substr $del2,$_,1; | |||||||||||||||||||||||||||||||||||||||||||||
| 335 | 816 | ▶ | my $ins2 = $ins2{$_} if exists $ins2{$_}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||
| 337 | # Insert/insert conflict. This is not a conflict if both inserts are identical. | ||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 816 | ▶ | if ($ins1 && $ins2 && !&_equal($ins1,$ins2)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
$ins1 and $ins2 and not &_equal($ins1, $ins2)
$ins1 and $ins2
MC/DC0%0/3
$ins1 and $ins2 and not &_equal($ins1, $ins2)
$ins1
$ins2
not &_equal($ins1, $ins2)
Truth table50%2/4
A and B and not(C)
A= $ins1B= $ins2C= not &_equal($ins1, $ins2)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | push @out, ('*'x20)."Start of conflict ".(++$conflict). | |||||||||||||||||||||||||||||||||||||||||||||
| 341 | " Insert to Primary, Insert to Secondary ".('*'x60)."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | push @out, @$ins1, ('*'x100)."\n", @$ins2; | |||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | push @out, ('*'x20)."End of conflict ".$conflict.('*'x80)."\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 345 | } elsif (!$conflict_type) { #Insert/Delete conflict | ||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | # Normal insertion - may be from $ins1 or $ins2. Apply the inser and junk both $ins1 and $ins2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 809 | ▶ | $ins1 ||= $ins2; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$ins1 ||= $ins2
MC/DC100%2/2
$ins1 ||= $ins2
$ins1
$ins2
Truth table100%3/3
A ||= B
A= $ins1B= $ins2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 809 | ▶ | push @out, @$ins1 if defined $ins1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 809 | undef $ins1; | |||||||||||||||||||||||||||||||||||||||||||||
| 354 | 809 | undef $ins2; | |||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||
| 357 | # Detect start of conflict 1 and 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 816 | ▶ | if (!$conflict_type && $d1 eq '*') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $conflict_type and $d1 eq "*"
MC/DC100%2/2
not $conflict_type and $d1 eq "*"
not $conflict_type
$d1 eq "*"
Truth table100%3/3
not(A) and B
A= not $conflict_typeB= $d1 eq "*"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 2 | push @out, ('*'x20)."Start of conflict ".(++$conflict). | |||||||||||||||||||||||||||||||||||||||||||||
| 361 | " Delete from Primary, Insert to Secondary ".('*'x60)."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 2 | $conflict_type = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 816 | ▶ | if (!$conflict_type && $d2 eq '*') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $conflict_type and $d2 eq "*"
MC/DC0%0/2
not $conflict_type and $d2 eq "*"
not $conflict_type
$d2 eq "*"
Truth table66%2/3
not(A) and B
A= not $conflict_typeB= $d2 eq "*"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | push @out, ('*'x20)."Start of conflict ".(++$conflict). | |||||||||||||||||||||||||||||||||||||||||||||
| 368 | " Delete from Secondary, Insert to Primary ".('*'x60)."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | $conflict_type = 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||
| 373 | # Handle case where we are in an Insert/Delete conflict block already | ||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 816 | ▶ | if ($conflict_type == 1) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 9 | ▶ | if ($d1 eq '*') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||
| 378 | # Deletion block continues... | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 7 | ▶ | push @defer,(@$ins2) if $ins2; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 7 | ▶ | push @defer,$line if !$d2; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | # handle end of block, dump out @defer and clear it | ||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 2 | push @out, ('*'x100)."\n",@defer; | |||||||||||||||||||||||||||||||||||||||||||||
| 386 | 2 | undef @defer; | |||||||||||||||||||||||||||||||||||||||||||||
| 387 | 2 | push @out, ('*'x20)."End of conflict ".$conflict.('*'x80)."\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 388 | 2 | $conflict_type = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 816 | ▶ | if ($conflict_type == 2) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | if ($d2 eq '*') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # Deletion block continues... | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | push @defer,(@$ins1) if $ins1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | push @defer,$line if !$d1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # handle end of block, dump out @defer and clear it | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | push @out, ('*'x100),"\n", @defer; | |||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | undef @defer; | |||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | push @out, ('*'x20)."End of conflict ".$conflict.('*'x80)."\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $conflict_type = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 816 | ▶ | last unless defined $line; # for end of file, don't want to push undef | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 808 | ▶ | push @out, $line unless ($d1 eq '-' || $d2 eq '-') && !$conflict_type; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$d1 eq "-" || $d2 eq "-" and not $conflict_type
$d1 eq "-" or $d2 eq "-"
MC/DC100%3/3
$d1 eq "-" || $d2 eq "-" and not $conflict_type
$d1 eq "-"
$d2 eq "-"
not $conflict_type
Truth table80%4/5
A or B and not(C)
A= $d1 eq "-"B= $d2 eq "-"C= not $conflict_type
| |||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 8 | $pkg->new($out_title, undef, \@out); | |||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | sub _error {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_error: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||
| 418 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||