| 1 | package SVN::Web::DiffParser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # $Id: Parser.pm,v 1.3 2006/04/13 01:47:37 fil Exp $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use 5.00404; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use vars qw( $VERSION ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | $VERSION = 0.62; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | #$VERSION = '0.62'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | #$VERSION = eval $VERSION; # see L<perlmodstyle> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | #################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my ( $package, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | changes => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | source => '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | }, $package; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my $parms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | if ( 1 == @args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ( 'HASH' eq ref $args[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | $parms = $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | my $diff = $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if ( ref $diff or $diff !~ /\n/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $diff or not $diff =~ /\n/
MC/DC0%0/2
ref $diff or not $diff =~ /\n/
ref $diff
not $diff =~ /\n/
Truth table0%0/3
A or not(B)
A= ref $diffB= not $diff =~ /\n/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $parms = { File => $diff }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $parms = { Diff => $diff }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $parms = {@args}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $self->__init($parms); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub __init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__init: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my ( $self, $parms ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | $self->{verbose} = 1 if $parms->{Verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $self->{simplify} = $parms->{Simplify}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $self->{strip} = $parms->{Strip}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if ( $parms->{File} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $self->parse_file( $parms->{File} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | elsif ( $parms->{Diff} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $self->parse( $parms->{Diff} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | #################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub source { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
source: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return $self->{source}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | #################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub changes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
changes: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $ret = $self->{changes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ($file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $ret = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | foreach my $ch ( @{ $self->{changes} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | unless $ch->filename1 eq $file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ch->filename1 eq $file or $ch->filename2 eq $file
MC/DC0%0/2
$ch->filename1 eq $file or $ch->filename2 eq $file
$ch->filename1 eq $file
$ch->filename2 eq $file
Truth table0%0/3
A or B
A= $ch->filename1 eq $fileB= $ch->filename2 eq $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | or $ch->filename2 eq $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | push @$ret, $ch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | return @$ret if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | return 0 + @$ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | #################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub files { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
files: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my %ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | foreach my $ch ( $self->changes ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $ret{ $ch->filename1 } = $ch->filename2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | return %ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | #################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub simplify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
simplify: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my @keep; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | my $prev; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | foreach my $ch ( $self->changes ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if ( $ch->type eq '' ) { # skip no-change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | undef($prev); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ($prev) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my $size = $prev->size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ## Combine ADD/REMOVE lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$prev->type ne $ch->type and $prev->filename1 eq $ch->filename1 and $prev->filename2 eq $ch->filename2 and $size == $ch->size
$prev->type ne $ch->type and $prev->filename1 eq $ch->filename1 and $prev->filename2 eq $ch->filename2
$prev->type ne $ch->type and $prev->filename1 eq $ch->filename1
MC/DC0%0/4
$prev->type ne $ch->type and $prev->filename1 eq $ch->filename1 and $prev->filename2 eq $ch->filename2 and $size == $ch->size
$prev->type ne $ch->type
$prev->filename1 eq $ch->filename1
$prev->filename2 eq $ch->filename2
$size == $ch->size
Truth table0%0/5
A and B and C and D
A= $prev->type ne $ch->typeB= $prev->filename1 eq $ch->filename1C= $prev->filename2 eq $ch->filename2D= $size == $ch->size
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | $prev->type ne $ch->type and # ADD->REMOVE or REMOVE->ADD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | $prev->filename1 eq $ch->filename1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | and $prev->filename2 eq $ch->filename2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | and $size == $ch->size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | { #close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | if ( $prev->type eq 'REMOVE' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
$prev->type eq "REMOVE" and $prev->line2 == $ch->line2 and $prev->line1 + $size == $ch->line1
$prev->type eq "REMOVE" and $prev->line2 == $ch->line2
MC/DC0%0/3
$prev->type eq "REMOVE" and $prev->line2 == $ch->line2 and $prev->line1 + $size == $ch->line1
$prev->type eq "REMOVE"
$prev->line2 == $ch->line2
$prev->line1 + $size == $ch->line1
Truth table0%0/4
A and B and C
A= $prev->type eq "REMOVE"B= $prev->line2 == $ch->line2C= $prev->line1 + $size == $ch->line1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | and $prev->line2 == $ch->line2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | and ( $prev->line1 + $size ) == $ch->line1 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $prev->{type} = 'MODIFY'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $prev->{lines} = $ch->{lines}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | undef($prev); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ▶ | elsif ( $prev->type eq 'ADD' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$prev->type eq "ADD" and $prev->line2 + $size == $ch->line2 and $prev->line1 == $ch->line1
$prev->type eq "ADD" and $prev->line2 + $size == $ch->line2
MC/DC0%0/3
$prev->type eq "ADD" and $prev->line2 + $size == $ch->line2 and $prev->line1 == $ch->line1
$prev->type eq "ADD"
$prev->line2 + $size == $ch->line2
$prev->line1 == $ch->line1
Truth table0%0/4
A and B and C
A= $prev->type eq "ADD"B= $prev->line2 + $size == $ch->line2C= $prev->line1 == $ch->line1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | and ( $prev->line2 + $size ) == $ch->line2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | and $prev->line1 == $ch->line1 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $prev->{type} = 'MODIFY'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | undef($prev); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # same size, same file, but not at the same spot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | push @keep, $ch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $prev = $ch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $self->{changes} = \@keep; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | #################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | sub parse_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_file: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | if ( ref $file ) { # assume it's a file handle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $self->{source} = 'user filehandle'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $fh = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $self->{source} = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $fh = IO::File->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | $fh->open($file) or croak "Unable to open $file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $self->{changes} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $self->{state} = { OK => 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $self->{state}{context} = "line $. of $self->{source}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $self->_parse_line($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $ok = $self->{state}{OK}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | delete $self->{state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | $self->simplify if $self->{simplify}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | return $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | #################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my ( $self, $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $self->{source} = "user string"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $self->{changes} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $self->{state} = { OK => 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my $l = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | while ( $text =~ /(.+?\n)/g ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $self->{state}{context} = "line $l of string"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $self->_parse_line($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $l++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my $ok = $self->{state}{OK}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | delete $self->{state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | $self->simplify if $self->{simplify}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | #################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub _parse_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_line: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my ( $self, $line ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | $self->{verbose} and warn "Parsing $line"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $state = $self->{state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | if ( $state->{unified} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $self->_unified_line($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | return if $state->{unified}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | elsif ( $state->{standard} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $self->_standard_line($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | return if $state->{standard}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $file = '(?:-r\d(?:\.\d+)+)|(?:[^-].+)'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if ( $line =~ /^diff\s+($file)\s+($file)\s*$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my @match = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | $self->{verbose} and warn "Diff $1 $2"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $state->{filename1} = $self->_filename( $match[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $state->{filename2} = $self->_filename( $match[1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | elsif ( $line =~ /^(\d+)(?:,\d+)?[acd](\d+)(?:,\d+)?$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $state->{standard} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | push @{ $self->{changes} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | at1 => $1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | line1 => $1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | at2 => $2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | line2 => $2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | filename1 => $state->{filename1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | filename2 => $state->{filename2}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | timestamp1 => '', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | timestamp2 => '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 'SVN::Web::DiffParser::Change'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | $self->{verbose} and warn "Standard diff line1=$1 line2=$2"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | ▶ | elsif ($line =~ /^--- (.+?)\t(.+)$/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$line =~ /^--- (.+?)\t(.+)$/ or $line =~ /^--- ([^\s]+)\s+(.+)$/
MC/DC0%0/2
$line =~ /^--- (.+?)\t(.+)$/ or $line =~ /^--- ([^\s]+)\s+(.+)$/
$line =~ /^--- (.+?)\t(.+)$/
$line =~ /^--- ([^\s]+)\s+(.+)$/
Truth table0%0/3
A or B
A= $line =~ /^--- (.+?)\t(.+)$/B= $line =~ /^--- ([^\s]+)\s+(.+)$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | or $line =~ /^--- ([^\s]+)\s+(.+)$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $state->{unified} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my $stamp = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my $name = $self->_filename($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | $self->{verbose} and warn "Unified diff"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | push @{ $self->{changes} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | type => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | filename1 => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | timestamp1 => $stamp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 'SVN::Web::DiffParser::Change'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | ▶ | elsif ($line =~ /^\*\*\* (.+?)\t(.+)$/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$line =~ /^\*\*\* (.+?)\t(.+)$/ or $line =~ /^\*\*\* ([^\s]+)\s+(.+)$/
MC/DC0%0/2
$line =~ /^\*\*\* (.+?)\t(.+)$/ or $line =~ /^\*\*\* ([^\s]+)\s+(.+)$/
$line =~ /^\*\*\* (.+?)\t(.+)$/
$line =~ /^\*\*\* ([^\s]+)\s+(.+)$/
Truth table0%0/3
A or B
A= $line =~ /^\*\*\* (.+?)\t(.+)$/B= $line =~ /^\*\*\* ([^\s]+)\s+(.+)$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | or $line =~ /^\*\*\* ([^\s]+)\s+(.+)$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | die "Context diff not yet supported at $state->{context}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | #################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | sub _filename { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_filename: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | return $file unless $self->{strip}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | my $n = $self->{strip}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | $file =~ s(^[^/]+/)() while $n--; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | return $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | #################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | sub _standard_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_standard_line: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my ( $self, $line ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | my %types = ( ' ' => '', '>' => 'ADD', '<' => 'REMOVE' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my $change = $self->{changes}[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | if ( $line =~ /^([<>])(.+)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my ( $mod, $text ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $mod = $types{$mod}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $self->_new_line( $mod, $text ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | if ( $line =~ /^---$/ ) { # pivot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | $self->{verbose} and warn "Pivot"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | delete $self->{state}{standard}; # let _parse_file deal with it | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | #################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | sub _unified_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unified_line: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my ( $self, $line ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my %types = ( ' ' => '', '+' => 'ADD', '-' => 'REMOVE' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $change = $self->{changes}[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | if ( $line =~ /^\+\+\+ (.+?)\t(.+)$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$line =~ /^\+\+\+ (.+?)\t(.+)$/ or $line =~ /^\+\+\+ ([^\s]+)\s+(.+)$/
MC/DC0%0/2
$line =~ /^\+\+\+ (.+?)\t(.+)$/ or $line =~ /^\+\+\+ ([^\s]+)\s+(.+)$/
$line =~ /^\+\+\+ (.+?)\t(.+)$/
$line =~ /^\+\+\+ ([^\s]+)\s+(.+)$/
Truth table0%0/3
A or B
A= $line =~ /^\+\+\+ (.+?)\t(.+)$/B= $line =~ /^\+\+\+ ([^\s]+)\s+(.+)$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | or $line =~ /^\+\+\+ ([^\s]+)\s+(.+)$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $change->{timestamp2} = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | $change->{filename2} = $self->_filename($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $change->{lines} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | die "Missing +++ line before $line" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | unless exists $change->{filename2} and defined $change->{filename2}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $change->{"filename2"} and defined $change->{"filename2"}
MC/DC0%0/2
exists $change->{"filename2"} and defined $change->{"filename2"}
exists $change->{"filename2"}
defined $change->{"filename2"}
Truth table0%0/3
A and B
A= exists $change->{"filename2"}B= defined $change->{"filename2"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my @match = $self->_detect_hunk_line($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | if (@match) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | if ( @{ $change->{lines} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $change = $self->_new_chunk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | @{$change}{qw( line1 size1 line2 size2 )} = @match; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | $change->{at1} = $change->{line1}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $change->{at2} = $change->{line2}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | return unless exists $change->{line1} and defined $change->{line1}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $change->{"line1"} and defined $change->{"line1"}
MC/DC0%0/2
exists $change->{"line1"} and defined $change->{"line1"}
exists $change->{"line1"}
defined $change->{"line1"}
Truth table0%0/3
A and B
A= exists $change->{"line1"}B= defined $change->{"line1"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if ( $line =~ /^([-+ ])(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my ( $mod, $text ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $mod = $types{$mod}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $self->_new_line( $mod, $text ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | # Anything else is the end of the diff, so fall through to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | # diff detection bit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $self->{state}{unified} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | sub _detect_hunk_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_detect_hunk_line: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my ( $self, $line ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | # pretty standard change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | # "@@ -l1,n1 +l2,n2 @@" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | if ( $line =~ /^\@\@ -(\d+),(\d+) [+](\d+),(\d+) \@\@$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | return ( $1, $2, $3, $4 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | # New files with only one line. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # "@@ -0,0 +1 @@" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | if ( $line =~ /^\@\@ -(\d+),(\d+) [+](\d+) \@\@$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | return ( $1, $2, $3, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | # Files that are only one line long, but get changed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | # "@@ -1 +1 @@" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | if ( $line =~ /^\@\@ -(\d+) [+](\d+) \@\@$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | return ( $1, 1, $2, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | # Files that are only one line long, and get new line. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | # "@@ -1 +1,n @@" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | if ( $line =~ /^\@\@ -(\d+) [+](\d+),(\d+) \@\@$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | return ( $1, 1, $2, $3 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | sub _new_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_type: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my ( $self, $mod ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $change = $self->{changes}[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | push @{ $self->{changes} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | filename1 => $change->{filename1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | filename2 => $change->{filename2}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | line1 => $change->{at1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | line2 => $change->{at2}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | at1 => $change->{at1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | at2 => $change->{at2}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | type => $mod, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | lines => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 'SVN::Web::DiffParser::Change'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | return $self->{changes}[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | sub _new_chunk { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_chunk: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my $change = $self->{changes}[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | push @{ $self->{changes} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | type => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | filename1 => $change->{filename1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | filename2 => $change->{filename2}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | lines => [] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 'SVN::Web::DiffParser::Change'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | return $self->{changes}[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | sub _new_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_line: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my ( $self, $mod, $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | $self->{verbose} and warn "_new_line"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | my $change = $self->{changes}[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | if ( defined $change->{type} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | if ( $change->{type} ne $mod ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | $self->{verbose} and warn "_new_type"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $change = $self->_new_type($mod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $change->{type} = $mod; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | $change->{at1}++ unless $mod eq 'ADD'; # - or ' ', advance in file1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | $change->{at2}++ unless $mod eq 'REMOVE'; # + or ' ', advance in file2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | push @{ $change->{lines} }, $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | ###################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | package SVN::Web::DiffParser::Change; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | sub filename1 { $_[0]->{filename1} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filename1: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | sub filename2 { $_[0]->{filename2} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filename2: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | sub line1 { $_[0]->{line1} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
line1: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | sub line2 { $_[0]->{line2} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
line2: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | sub size { 0 + @{ $_[0]->{lines} } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
size: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | sub type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | return $self->{type} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | if $self->{type} eq 'ADD' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | or $self->{type} eq 'REMOVE' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | or $self->{type} eq 'MODIFY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->{"type"} eq "ADD" or $self->{"type"} eq "REMOVE" or $self->{"type"} eq "MODIFY"
$self->{"type"} eq "ADD" or $self->{"type"} eq "REMOVE"
MC/DC0%0/3
$self->{"type"} eq "ADD" or $self->{"type"} eq "REMOVE" or $self->{"type"} eq "MODIFY"
$self->{"type"} eq "ADD"
$self->{"type"} eq "REMOVE"
$self->{"type"} eq "MODIFY"
Truth table0%0/4
A or B or C
A= $self->{"type"} eq "ADD"B= $self->{"type"} eq "REMOVE"C= $self->{"type"} eq "MODIFY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | sub text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
text: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my ( $self, $n ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | return @{ $self->{lines} } if 1 == @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | return $self->{lines}[$n]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||