| 1 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | XML::Diff -- XML DOM-Tree based Diff & Patch Module | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | my $diff = XML::Diff->new(); | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | # to generate a diffgram of two XML files, use compare. | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # $old and $new can be filepaths, XML as a string, | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # XML::LibXML::Document or XML::LibXML::Element objects. | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # The diffgram is a XML::LibXML::Document by default. | ||||||||||||||||||||||||||||||||||||||||||
| 15 | my $diffgram = $diff->compare( | ||||||||||||||||||||||||||||||||||||||||||
| 16 | -old => $old_xml, | ||||||||||||||||||||||||||||||||||||||||||
| 17 | -new => $new_xml, | ||||||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | # To patch an XML document, an patch. $old and $diffgram | ||||||||||||||||||||||||||||||||||||||||||
| 21 | # follow the same formatting rules as compare. | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # The resulting XML is a XML::LibXML::Document by default. | ||||||||||||||||||||||||||||||||||||||||||
| 23 | my $patched = $diff->patch( | ||||||||||||||||||||||||||||||||||||||||||
| 24 | -old => $old, | ||||||||||||||||||||||||||||||||||||||||||
| 25 | -diffgram => $diffgram, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | This module provides methods for generating and applying an XML | ||||||||||||||||||||||||||||||||||||||||||
| 31 | diffgram of two related XML files. The basis of the algorithm | ||||||||||||||||||||||||||||||||||||||||||
| 32 | is tree-wise comparison using the DOM model as provided by | ||||||||||||||||||||||||||||||||||||||||||
| 33 | XML::LibXML. | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | The Diffgram is well-formed XML in the XVCS namespance and | ||||||||||||||||||||||||||||||||||||||||||
| 36 | supports update, insert, delete and move operations. It is | ||||||||||||||||||||||||||||||||||||||||||
| 37 | meant to be human and machine readable. It uses XPath expressions | ||||||||||||||||||||||||||||||||||||||||||
| 38 | for locating the nodes to operate on. See the below B<DIFFGRAM> | ||||||||||||||||||||||||||||||||||||||||||
| 39 | section for the exact syntax. | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | The motivation and alogrithm used by this module is discussed in | ||||||||||||||||||||||||||||||||||||||||||
| 42 | B<MOTIVATION> below. | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 45 | package XML::Diff; | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | ▶ | use Digest::MD5; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | ▶ | use Algorithm::Diff qw( traverse_sequences ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | #debug aid | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | # match constants | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | ▶ | use constant HARD_MATCH => 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | use constant SOFT_MATCH => 2; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | use constant BRANCH_MATCH => 3; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | use constant STRUCTURE_MATCH => 4; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | # action constants | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | ▶ | use constant TREE_MOVE => 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | ▶ | use constant LOCAL_MOVE => 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | ▶ | use constant INSERT => 2; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | ▶ | use constant DELETE => 3; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | ▶ | use constant UPDATE => 4; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | ▶ | use constant NOOP => 5; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | # Module mode constants | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | ▶ | use constant NONE => 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | ▶ | use constant COMPARE => 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | use constant PATCH => 2; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | ▶ | use vars qw($VERSION $DEBUG); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | $VERSION = "0.05"; | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | =head1 PUBLIC METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | =head2 new (Constructor) | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | The Constructor takes no arguments. It merely creates the object | ||||||||||||||||||||||||||||||||||||||||||
| 84 | for using the B<compare> and B<patch> methods on. | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 87 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 4 | my $pkg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 4 | my %in = @_; | |||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 4 | my $self = { | |||||||||||||||||||||||||||||||||||||||||
| 93 | parser => XML::LibXML->new(), | ||||||||||||||||||||||||||||||||||||||||||
| 94 | pkg => $pkg, | ||||||||||||||||||||||||||||||||||||||||||
| 95 | ns => ['http://www.xvcs.org/','xvcs',0], | ||||||||||||||||||||||||||||||||||||||||||
| 96 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 4 | bless($self,$pkg); | |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 4 | ▶ | if( $XML::Diff::DEBUG ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 4 | $self->{parser}->keep_blanks(0); | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | =head2 compare | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | Compares two XML DOM trees and returns a diffgram for converting one | ||||||||||||||||||||||||||||||||||||||||||
| 114 | into the other. The default output method is a XML::LibXML::Document | ||||||||||||||||||||||||||||||||||||||||||
| 115 | object. However there are number of switches to alter this behavior. | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | =item -old | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | The old document to compare. Can be XML in a string, path to an | ||||||||||||||||||||||||||||||||||||||||||
| 122 | XML document, a XML::LibXML::Document or XML::LibXML::Element object | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | =item -new | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | The new document to compare. Can be XML in a string, path to an | ||||||||||||||||||||||||||||||||||||||||||
| 127 | XML document, a XML::LibXML::Document or XML::LibXML::Element object | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | =item -asString | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | If provided, the diffgram is returned via the toString(1) method | ||||||||||||||||||||||||||||||||||||||||||
| 132 | of XML::LibXML | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | =item -asFile | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | Must provide the filepath to write the diffgram to. | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 141 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub compare { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my %in = @_; | |||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | # init | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $self->{ID} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $self->{_MODE} = COMPARE; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $self->{old}->{lookup} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $self->{new}->{lookup} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | # get DOM objects | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $self->_getDoc( 'old', $in{-old} ); | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $self->_getDoc( 'new', $in{-new} ); | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | # diffgram we will return | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $self->{diffgram} = $self->{parser}->createDocument(); | |||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $self->{diffroot} = $self->{diffgram}->createElement('xvcs:diffgram' ); | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $self->{diffroot}->setNamespace(@{$self->{ns}}); | |||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $self->{diffgram}->setDocumentElement( $self->{diffroot} ); | |||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | # generate the Diff | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $self->_debug( "-- Phase I: ID Matching (unimplemented) --" ); | |||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $self->_debug( "-- Phase II: Compute Hashes & Weights --" ); | |||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $self->_debug( "old ------" ); | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $self->_buildTree($self->{old}->{root},$self->{old}->{lookup},1); | |||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $self->_debug( "new ------" ); | |||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $self->_buildTree($self->{new}->{root},$self->{new}->{lookup}); | |||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $self->_debug( "-- Phase III: Match by weight --" ); | |||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $self->_weightmatch(HARD_MATCH); | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $self->_weightmatch(); | |||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if( $XML::Diff::DEBUG ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $self->_debug( " MATCH_STATS ---------------------------------" ); | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $self->_debug( "Hard Matches: $self->{MATCH_COUNT}->{1}" ); | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $self->_debug( "Structure Matches: $self->{MATCH_COUNT}->{4}" ); | |||||||||||||||||||||||||||||||||||||||||
| 182 | # exit; | ||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $self->_debug( "-- Phase IV: Propagate Matchings by structure (unimplemented) --" ); | |||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $self->_debug( "-- Phase V: Generate Diffgram --" ); | |||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $self->_markChanges($self->{new}->{root}); | |||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $self->_markChanges($self->{old}->{root},1); | |||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if( $XML::Diff::DEBUG ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $self->_debug( " OLD ---------------------------------" ); | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $self->_debug( $self->{old}->{root}->toString(1) ); | |||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $self->_debug(); | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $self->_debug( "\n CMP ----------------------------------" ); | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $self->_debug( $self->{new}->{root}->toString(1) ); | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $self->_debug(); | |||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | foreach my $ref ( sort { $a->{rank} <=> $b->{rank} } values %{$self->{change}} ) { | |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $self->_processChange( $ref ); | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my $return; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if( $in{-asString} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $return = $self->{diffgram}->toString(1); | |||||||||||||||||||||||||||||||||||||||||
| 208 | } elsif( $in{-asFile} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $return = $self->{diffgram}->toFile($in{-asFile}, 1); | |||||||||||||||||||||||||||||||||||||||||
| 210 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $return = $self->{diffgram}; | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | # clean-up | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | undef $self->{old}; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | undef $self->{new}; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | undef $self->{diffgram}; | |||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | undef $self->{diffroot}; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | undef $self->{clone_lookup}; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | undef $self->{change_rank}; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | undef $self->{change}; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | undef $self->{change_registry}; | |||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $self->{_MODE} = NONE; | |||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | return $return; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | =head2 patch | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | Applies a diffgram to an XML document to generate a new XML document. | ||||||||||||||||||||||||||||||||||||||||||
| 234 | The default output method is a XML::LibXML::Document object. However | ||||||||||||||||||||||||||||||||||||||||||
| 235 | there are number of switches to alter this behavior. | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | =item -old | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | The old document to compare. Can be XML in a string, path to an | ||||||||||||||||||||||||||||||||||||||||||
| 242 | XML document, a XML::LibXML::Document or XML::LibXML::Element object | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | =item -diffgram | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | The diffgram to apply. Can be XML in a string, path to an | ||||||||||||||||||||||||||||||||||||||||||
| 247 | XML document, a XML::LibXML::Document or XML::LibXML::Element object | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | =item -asString | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | If provided, the new document is returned via the toString(1) method | ||||||||||||||||||||||||||||||||||||||||||
| 252 | of XML::LibXML | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | =item -asFile | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | Must provide the filepath to write the new document to. | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 261 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | sub patch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
patch: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | my %in = @_; | |||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $self->{_MODE} = PATCH; | |||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $self->_getDoc( 'old', $in{-old} ); | |||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $self->_getDoc( 'diff', $in{-diffgram} ); | |||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | # gotta find the nodes to be moved before we do any of the actual actions, | ||||||||||||||||||||||||||||||||||||||||||
| 272 | # otherwise our xpath's are off | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | #$self->_debug( "original:\n".$self->{old}->{doc}->toString(1) ); | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | foreach my $patch ( $self->{diff}->{root}->childNodes ) { | |||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $name = $patch->nodeName(); | |||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $self->_debug( "applying:\n".$patch->toString(1) ); | |||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | for($name) { | |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | /xvcs:insert/ && do { $self->_applyInsert( $patch ); last; }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | /xvcs:update/ && do { $self->_applyUpdate( $patch ); last; }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | /xvcs:delete/ && do { $self->_applyDelete( $patch ); last; }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | /xvcs:move/ && do { $self->_applyMove( $patch ); last; }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | #$self->_debug( "intermediate:\n".$self->{old}->{doc}->toString(1) ); | ||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my $return; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | if( $in{-asString} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $return = $self->{old}->{doc}->toString(1); | |||||||||||||||||||||||||||||||||||||||||
| 291 | } elsif( $in{-asFile} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $return = $self->{old}->{doc}->toFile($in{-asFile}, 1); | |||||||||||||||||||||||||||||||||||||||||
| 293 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $return = $self->{old}->{doc}; | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | undef $self->{old}; | |||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | undef $self->{diff}; | |||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $self->{_MODE} = NONE; | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | return $return; | |||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | =head1 DIFFGRAM | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | The diffgram is an XML document in the xvcs namespace. It's root is always | ||||||||||||||||||||||||||||||||||||||||||
| 310 | I<e<xvcs:diffgram xmlns:xvcs="http://www.xvcs.org/">>. Below diff operations | ||||||||||||||||||||||||||||||||||||||||||
| 311 | are attached in order of application. Order I<is> significant, since the | ||||||||||||||||||||||||||||||||||||||||||
| 312 | way that nodes are idenitified in the default version of the diffgram is by | ||||||||||||||||||||||||||||||||||||||||||
| 313 | an XPath expression, i.e. the diffgram may change the XML document in such | ||||||||||||||||||||||||||||||||||||||||||
| 314 | a way that XPath expressions are either not yet valid or will not be anymore | ||||||||||||||||||||||||||||||||||||||||||
| 315 | at a later point the diffgram (see B<KNOWN PROBLEMS> for a discussion of this | ||||||||||||||||||||||||||||||||||||||||||
| 316 | limitation). | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | The supported diffgram operations are: | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | =head2 xcvs:update | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | Update operations covers a number of sub-operations, i.e. it can be used | ||||||||||||||||||||||||||||||||||||||||||
| 323 | for Text node changes, attribute add, delete and modification. An example | ||||||||||||||||||||||||||||||||||||||||||
| 324 | of a Text Node change is: | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | <xvcs:update id="18" first-child-of="/root/block[2]/list/item[2]"> | ||||||||||||||||||||||||||||||||||||||||||
| 327 | <xvcs:old-value>Old Value</xvcs:old-value> | ||||||||||||||||||||||||||||||||||||||||||
| 328 | <xvcs:new-value>New Value</xvcs:new-value> | ||||||||||||||||||||||||||||||||||||||||||
| 329 | </xvcs:update> | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | Attribute updates are: | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | <xvcs:update id="31" first-child-of="/root/block[5]"> | ||||||||||||||||||||||||||||||||||||||||||
| 334 | <xvcs:attr-insert name="some_attribute" value="new value"/> | ||||||||||||||||||||||||||||||||||||||||||
| 335 | </xvcs:update> | ||||||||||||||||||||||||||||||||||||||||||
| 336 | <xvcs:update id="32" first-child-of="/root/block[6]"> | ||||||||||||||||||||||||||||||||||||||||||
| 337 | <xvcs:attr-insert name="some_attribute2" value="old value"/> | ||||||||||||||||||||||||||||||||||||||||||
| 338 | </xvcs:update> | ||||||||||||||||||||||||||||||||||||||||||
| 339 | <xvcs:update id="33" first-child-of="/root/block[6]"> | ||||||||||||||||||||||||||||||||||||||||||
| 340 | <xvcs:attr-update name="some_attribute3" | ||||||||||||||||||||||||||||||||||||||||||
| 341 | old-value="old value" new-value="new value/> | ||||||||||||||||||||||||||||||||||||||||||
| 342 | </xvcs:update> | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | =head2 xcvs:delete | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | <xvcs:delete id="29" follows="/root/block[3]"> | ||||||||||||||||||||||||||||||||||||||||||
| 347 | <block> | ||||||||||||||||||||||||||||||||||||||||||
| 348 | <node>value</node> | ||||||||||||||||||||||||||||||||||||||||||
| 349 | </block> | ||||||||||||||||||||||||||||||||||||||||||
| 350 | </xvcs:delete> | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | =head2 xcvs:move | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | <xvcs:move id="11" follows="/root/block[1]"> | ||||||||||||||||||||||||||||||||||||||||||
| 355 | <xvcs:source first-child-of="/root"/> | ||||||||||||||||||||||||||||||||||||||||||
| 356 | </xvcs:move> | ||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | =head2 xcvs:insert | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | <xvcs:insert id="34" follows="/root/block[1]"> | ||||||||||||||||||||||||||||||||||||||||||
| 361 | <block> | ||||||||||||||||||||||||||||||||||||||||||
| 362 | <node>value</node> | ||||||||||||||||||||||||||||||||||||||||||
| 363 | </block> | ||||||||||||||||||||||||||||||||||||||||||
| 364 | </xvcs:insert> | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | All operations share the same attributes to identify the operation | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | =item id | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | The xvcs:id of the node affected (currently serves only internal uses) | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | =item follows | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | The XPath to the prior sibling of the node affected. We use relative | ||||||||||||||||||||||||||||||||||||||||||
| 377 | identification since insert and move destination do not affect an | ||||||||||||||||||||||||||||||||||||||||||
| 378 | existing node location. The rest of the operations follow this methodology | ||||||||||||||||||||||||||||||||||||||||||
| 379 | for consistency and to allow simple reversing of an operation | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | =item first-child-of | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | If the XPath for the node does not have a prior sibling, we use the | ||||||||||||||||||||||||||||||||||||||||||
| 384 | XPath to the parent and note that our operation affects the first child | ||||||||||||||||||||||||||||||||||||||||||
| 385 | of that parent | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | =item text | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | Since XPath does not have an expression for locating a text node, | ||||||||||||||||||||||||||||||||||||||||||
| 390 | Nodes following Text nodes are identified by the XPath to the prior | ||||||||||||||||||||||||||||||||||||||||||
| 391 | sibling that is an Element and the text attribute to tell it to | ||||||||||||||||||||||||||||||||||||||||||
| 392 | skip the next text node before starting the operation | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | =head1 KNOWN PROBLEMS | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | =item * Does not handle any Node Types Other than Element, Attribute and Text | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | =item * Diffgram operations are not guaranteed to be atomic | ||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | =item * Delete Operations on Nodes between two Text nodes are not reversable | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | =head1 MOTIVATIONS | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | The Algorithm used in this Module is loosely based on the one described | ||||||||||||||||||||||||||||||||||||||||||
| 411 | by Gregory Cobena in his Doctoral Dissertation on XyDiff. The decision to | ||||||||||||||||||||||||||||||||||||||||||
| 412 | create a new implementation of this Algorithm rather than just create an | ||||||||||||||||||||||||||||||||||||||||||
| 413 | XS interface to the existing XyDiff algorithm was based on wanting a perl | ||||||||||||||||||||||||||||||||||||||||||
| 414 | implementation with less external dependencies and greater flexibility to | ||||||||||||||||||||||||||||||||||||||||||
| 415 | add divergent features (such as using XPath for node identitication rather | ||||||||||||||||||||||||||||||||||||||||||
| 416 | than XIDs). | ||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | =head1 PRIVATE METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | This section is mostly for reference if you are going through the code, | ||||||||||||||||||||||||||||||||||||||||||
| 422 | it serves no purpose if you are just wanting to use the exposed interface | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | =head2 _getDoc | ||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 427 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 428 | 3 | ▶ | sub _getDoc { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_getDoc: called CC=6 SCAR=18.8
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 430 | 3 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 431 | 3 | my $source = shift; | |||||||||||||||||||||||||||||||||||||||||
| 432 | 3 | my $doc; | |||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 3 | ▶ | if( ref $source ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | 1 | ▶ | if( $source->isa( 'XML::LibXML::Document' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 436 | # since we're likely to mess around with the object, we clone it | ||||||||||||||||||||||||||||||||||||||||||
| 437 | # for our internal use | ||||||||||||||||||||||||||||||||||||||||||
| 438 | 1 | $self->{$type}->{root} = $source->documentElement()->cloneNode(1); | |||||||||||||||||||||||||||||||||||||||||
| 439 | } elsif( $source->isa( 'XML::LibXML::Element' ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 440 | # since we're likely to mess around with the object, we clone it | ||||||||||||||||||||||||||||||||||||||||||
| 441 | # for our internal use | ||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | $self->_debug( "source was libXML element" ); | |||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | $self->{$type}->{root} = $source->cloneNode(1); | |||||||||||||||||||||||||||||||||||||||||
| 444 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | 1 | $self->{$type}->{doc} = $self->{parser}->createDocument(); | |||||||||||||||||||||||||||||||||||||||||
| 449 | 1 | $self->{$type}->{doc}->setDocumentElement( $source ); | |||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 452 | 2 | ▶ | if( $source !~ /\n/ && -e $source ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $source =~ /\n/ and -e $source
MC/DC50%1/2
not $source =~ /\n/ and -e $source
not $source =~ /\n/
-e $source
Truth table66%2/3
not(A) and B
A= not $source =~ /\n/B= -e $source
| |||||||||||||||||||||||||||||||||||||||||||
| 453 | 1 | $self->{$type}->{doc} = $self->{parser}->parse_file( $source ); | |||||||||||||||||||||||||||||||||||||||||
| 454 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 455 | 1 | $self->{$type}->{doc} = $self->{parser}->parse_string( $source ); | |||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||
| 457 | 2 | $self->{$type}->{root} = $self->{$type}->{doc}->documentElement(); | |||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | #$self->{$type}->{doc}->indexElements(); | ||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | =head2 _buildTree | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 471 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | sub _buildTree { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_buildTree: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | my $lookup = shift; | |||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my $old = shift; | |||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | my $position = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | my $signature; | |||||||||||||||||||||||||||||||||||||||||
| 479 | my $thumbprint; | ||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my $weight; | |||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | # currently we only look at Element and Text nodes (Attribute nodes | ||||||||||||||||||||||||||||||||||||||||||
| 483 | # we handle as a known sub-element of Element nodes) | ||||||||||||||||||||||||||||||||||||||||||
| 484 | #next unless( $node->nodeType == 3 || $node->nodeType == 1 ); | ||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||
| 486 | # need to consider full, content and structure matches for better diffs | ||||||||||||||||||||||||||||||||||||||||||
| 487 | # but that's for the future.. right now we just do structure | ||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | my $nodeType = $node->nodeType; | |||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | if( $node->nodeType == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 490 | #$self->_debug( "- element node -" ); | ||||||||||||||||||||||||||||||||||||||||||
| 491 | # XML_ELEMENT_NODE= 1, | ||||||||||||||||||||||||||||||||||||||||||
| 492 | # XML_ATTRIBUTE_NODE= 2, | ||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | $signature = $node->nodeName(); | |||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | $thumbprint = $signature; | |||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | my $p; | |||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | foreach my $child ( $node->childNodes() ) { | |||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | my($thumbprint2,$signature2) = $self->_buildTree( $child, $lookup, $old, $p ); | |||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | $thumbprint .= $thumbprint2; | |||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | $signature .= $signature2; | |||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $p++; | |||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | foreach my $attr ( sort {$a->nodeName cmp $b->nodeName } $node->attributes() ) { | |||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $weight += length($attr->nodeName); | |||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | $thumbprint .= $attr->nodeName(); | |||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||
| 508 | } elsif( $nodeType == 3 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 509 | #$self->_debug( "- text node -" ); | ||||||||||||||||||||||||||||||||||||||||||
| 510 | # XML_TEXT_NODE= 3, | ||||||||||||||||||||||||||||||||||||||||||
| 511 | # text node hashes are their text value | ||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $signature = 'TEXT'; | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | $thumbprint = $signature.$node->textContent(); | |||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $weight = length($thumbprint); | |||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | } elsif( $nodeType == 4 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 517 | #$self->_debug( "- cdata section -" ); | ||||||||||||||||||||||||||||||||||||||||||
| 518 | # XML_CDATA_SECTION_NODE= 4, | ||||||||||||||||||||||||||||||||||||||||||
| 519 | # cdata section | ||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | $signature = 'CDATA'; | |||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | $thumbprint = $signature.$node->textContent(); | |||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | $weight = length($thumbprint); | |||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | } elsif( $nodeType == 7 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 525 | #$self->_debug( "- processing instruction -" ); | ||||||||||||||||||||||||||||||||||||||||||
| 526 | # XML_PI_NODE= 7, | ||||||||||||||||||||||||||||||||||||||||||
| 527 | # processing instruction | ||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | $signature = 'PI'; | |||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | $thumbprint = $signature; | |||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | $weight = 5; | |||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | } elsif( $nodeType == 8 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 533 | #$self->_debug( "- comment node -" ); | ||||||||||||||||||||||||||||||||||||||||||
| 534 | # XML_COMMENT_NODE= 8, | ||||||||||||||||||||||||||||||||||||||||||
| 535 | # comment node | ||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | $signature = 'COMMENT'; | |||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | $thumbprint = $signature.$node->textContent(); | |||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | $weight = length($thumbprint); | |||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 542 | #$self->_debug( "- UNHANDLED NODE TYPE -" ); | ||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | # unhandled | ||||||||||||||||||||||||||||||||||||||||||
| 545 | # XML_ENTITY_REF_NODE= 5, | ||||||||||||||||||||||||||||||||||||||||||
| 546 | # XML_ENTITY_NODE= 6, | ||||||||||||||||||||||||||||||||||||||||||
| 547 | # XML_DOCUMENT_NODE= 9, | ||||||||||||||||||||||||||||||||||||||||||
| 548 | # XML_DOCUMENT_TYPE_NODE= 10, | ||||||||||||||||||||||||||||||||||||||||||
| 549 | # XML_DOCUMENT_FRAG_NODE= 11, | ||||||||||||||||||||||||||||||||||||||||||
| 550 | # XML_NOTATION_NODE= 12, | ||||||||||||||||||||||||||||||||||||||||||
| 551 | # XML_HTML_DOCUMENT_NODE= 13, | ||||||||||||||||||||||||||||||||||||||||||
| 552 | # XML_DTD_NODE= 14, | ||||||||||||||||||||||||||||||||||||||||||
| 553 | # XML_ELEMENT_DECL= 15, | ||||||||||||||||||||||||||||||||||||||||||
| 554 | # XML_ATTRIBUTE_DECL= 16, | ||||||||||||||||||||||||||||||||||||||||||
| 555 | # XML_ENTITY_DECL= 17, | ||||||||||||||||||||||||||||||||||||||||||
| 556 | # XML_NAMESPACE_DECL= 18, | ||||||||||||||||||||||||||||||||||||||||||
| 557 | # XML_XINCLUDE_START= 19, | ||||||||||||||||||||||||||||||||||||||||||
| 558 | # XML_XINCLUDE_END= 20 | ||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | my $md5 = Digest::MD5->new(); | |||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | $md5->add($signature); | |||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my $hash = $md5->b64digest(); | |||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my $node_id = $$node; | |||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my $md5_2 = Digest::MD5->new(); | |||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | $md5_2->add($thumbprint); | |||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | $thumbprint = $md5_2->b64digest(); | |||||||||||||||||||||||||||||||||||||||||
| 570 | #$self->_debug( "$node_id\t$weight\t$hash" ); | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my $id; | |||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | push(@{$lookup->{hash}->{$hash}->{$position}},$node); | |||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | ▶ | if( !$lookup->{hash}->{$hash}->{max} || $lookup->{hash}->{$hash}->{max} <= $position ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $lookup->{"hash"}{$hash}{"max"} or $lookup->{"hash"}{$hash}{"max"} <= $position
MC/DC0%0/2
not $lookup->{"hash"}{$hash}{"max"} or $lookup->{"hash"}{$hash}{"max"} <= $position
not $lookup->{"hash"}{$hash}{"max"}
$lookup->{"hash"}{$hash}{"max"} <= $position
Truth table0%0/3
not(A) or B
A= not $lookup->{"hash"}{$hash}{"max"}B= $lookup->{"hash"}{$hash}{"max"} <= $position
| |||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | $lookup->{hash}->{$hash}->{max} = $position; | |||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | #if( !$self->{_HARD_MATCH} && @{$lookup->{hash}->{$hash}} > 100 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 579 | # $self->{_HARD_MATCH} = 1; | ||||||||||||||||||||||||||||||||||||||||||
| 580 | # $self->_debug( "need to consider hard match.." ); | ||||||||||||||||||||||||||||||||||||||||||
| 581 | #} | ||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | if( $old ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | $id = ++$self->{ID}; | |||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | if( $nodeType == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $node->setAttribute('xvcs:id',$id ); | |||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | $lookup->{id}->{$id} = $node; | |||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | push(@{$lookup->{thumbprint}->{$thumbprint}->{$position}},$node); | |||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | if( !$lookup->{thumbprint}->{$thumbprint}->{max} || $lookup->{thumbprint}->{$thumbprint}->{max} <= $position ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $lookup->{"thumbprint"}{$thumbprint}{"max"} or $lookup->{"thumbprint"}{$thumbprint}{"max"} <= $position
MC/DC0%0/2
not $lookup->{"thumbprint"}{$thumbprint}{"max"} or $lookup->{"thumbprint"}{$thumbprint}{"max"} <= $position
not $lookup->{"thumbprint"}{$thumbprint}{"max"}
$lookup->{"thumbprint"}{$thumbprint}{"max"} <= $position
Truth table0%0/3
not(A) or B
A= not $lookup->{"thumbprint"}{$thumbprint}{"max"}B= $lookup->{"thumbprint"}{$thumbprint}{"max"} <= $position
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $lookup->{thumbprint}->{$thumbprint}->{max} = $position; | |||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||
| 593 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $weight += length($signature); | |||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | $lookup->{nodes}->{$node_id} = [$hash,$weight,$id,$position,$thumbprint]; | |||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | return($thumbprint,$hash); | |||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | =head2 _weightmatch | ||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 606 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | sub _weightmatch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_weightmatch: not called CC=33 SCAR=70.2
| |||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | my $match_type = shift || STRUCTURE_MATCH; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 4
MC/DC0%0/1
shift() || 4
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | my @queue = ($self->{new}->{root}); | |||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | my $lookup = $self->{old}->{lookup}; | |||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | my $newlookup = $self->{new}->{lookup}; | |||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | while ( my $node = shift @queue ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | my($hash,$weight,$id,$position,$thumbprint) = @{$newlookup->{nodes}->{$$node}}; | |||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | ▶ | if( $XML::Diff::DEBUG ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | my $node_name = $node->nodeName() || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$node->nodeName || ''
MC/DC0%0/1
$node->nodeName || ''
$node->nodeName
Truth table0%0/2
A
A= $node->nodeName
| |||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | $self->_debug( "$$node\t$weight\t$node_name\t$hash" ); | |||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | if ( $newlookup->{match_type}->{$$node} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | $self->_debug( " already matched this node.. WTF!" ); | |||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | #my $hard_match = $lookup->{thumbprint}->{$thumbprint}; | ||||||||||||||||||||||||||||||||||||||||||
| 624 | #if( $hard_match ) { | ||||||||||||||||||||||||||||||||||||||||||
| 625 | # my $count = @$hard_match; | ||||||||||||||||||||||||||||||||||||||||||
| 626 | # $self->_debug( " got $count hard matches for $thumbprint" ); | ||||||||||||||||||||||||||||||||||||||||||
| 627 | # if( $count > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 628 | # $self->_debug( $node->toString(1) ); | ||||||||||||||||||||||||||||||||||||||||||
| 629 | # exit; | ||||||||||||||||||||||||||||||||||||||||||
| 630 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 631 | #} | ||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | my $candidates; | |||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | if( $match_type == HARD_MATCH ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | $candidates = $lookup->{thumbprint}->{$thumbprint}; | |||||||||||||||||||||||||||||||||||||||||
| 635 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | $candidates = $lookup->{hash}->{$hash}; | |||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | my $candidate; | |||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | ▶ | if( $candidates ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | # need to find the best candidate | ||||||||||||||||||||||||||||||||||||||||||
| 642 | # first consider position in parent, so that we avoid moves | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | my $likely; | |||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | my $distance = 0; | |||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | my $max = $candidates->{max}; | |||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | $self->_debug( " max position => $max" ); | |||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | while( !$likely ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my @likely; | |||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | my $forward = $position + $distance; | |||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | my $back = $position - $distance; | |||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | $self->_debug( " checking $forward and $back" ); | |||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | my $check; | |||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | if( $forward != $back && $forward <= $max ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$forward != $back and $forward <= $max
MC/DC0%0/2
$forward != $back and $forward <= $max
$forward != $back
$forward <= $max
Truth table0%0/3
A and B
A= $forward != $backB= $forward <= $max
| |||||||||||||||||||||||||||||||||||||||||||
| 656 | # first time we hit this loop forward and back are the same, so we don't | ||||||||||||||||||||||||||||||||||||||||||
| 657 | # want to pull the same set twice | ||||||||||||||||||||||||||||||||||||||||||
| 658 | # we also don't want to push beyond our bounds | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | $check++; | |||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ▶ | if( exists( $candidates->{$forward} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 662 | # while we're looking at candidates, prune the ones already matched | ||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | my @l; | |||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | foreach my $node (@{$candidates->{$forward}}) { | |||||||||||||||||||||||||||||||||||||||||
| 665 | # check that this node hasn't been matched already | ||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | if( $lookup->{nodes}->{$$node} && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$lookup->{"nodes"}{$$node} and $lookup->{"nodes"}{$$node}[0]
MC/DC0%0/2
$lookup->{"nodes"}{$$node} and $lookup->{"nodes"}{$$node}[0]
$lookup->{"nodes"}{$$node}
$lookup->{"nodes"}{$$node}[0]
Truth table0%0/3
A and B
A= $lookup->{"nodes"}{$$node}B= $lookup->{"nodes"}{$$node}[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 667 | $lookup->{nodes}->{$$node}->[0] ) { | ||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | push( @l, $node ); | |||||||||||||||||||||||||||||||||||||||||
| 669 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | $self->_debug( "removing previously matched node from set" ); | |||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | if( @l ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | $candidates->{$forward} = \@l; | |||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | push( @likely, @l ); | |||||||||||||||||||||||||||||||||||||||||
| 676 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | delete $candidates->{$forward}; | |||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | if( $back >= 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 683 | # once, we get into negative territory, we don't check | ||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | $check++; | |||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | if( exists( $candidates->{$back} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 688 | # while we're looking at candidates, prune the ones already matched | ||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | my @l; | |||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | foreach my $node (@{$candidates->{$back}}) { | |||||||||||||||||||||||||||||||||||||||||
| 691 | # check that this node hasn't been matched already | ||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | if( $lookup->{nodes}->{$$node} && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$lookup->{"nodes"}{$$node} and $lookup->{"nodes"}{$$node}[0]
MC/DC0%0/2
$lookup->{"nodes"}{$$node} and $lookup->{"nodes"}{$$node}[0]
$lookup->{"nodes"}{$$node}
$lookup->{"nodes"}{$$node}[0]
Truth table0%0/3
A and B
A= $lookup->{"nodes"}{$$node}B= $lookup->{"nodes"}{$$node}[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 693 | $lookup->{nodes}->{$$node}->[0] ) { | ||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | push( @l, $node ); | |||||||||||||||||||||||||||||||||||||||||
| 695 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | $self->_debug( "removing previously matched node from set" ); | |||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | ▶ | if( @l ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | $candidates->{$back} = \@l; | |||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | push( @likely, @l ); | |||||||||||||||||||||||||||||||||||||||||
| 702 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | delete $candidates->{$back}; | |||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | ▶ | if( !$check ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | $self->_debug( "we give up: ".join(',',keys %$candidates)); | |||||||||||||||||||||||||||||||||||||||||
| 710 | # neither forward nor back had possible matches, we are done trying | ||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||
| 714 | # check if we end up with any likely set | ||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | ▶ | if( @likely ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | $likely = \@likely; | |||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||
| 719 | # ready for another round? | ||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | $distance++; | |||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||
| 723 | # then consider closests weight as an approximation of content and/or | ||||||||||||||||||||||||||||||||||||||||||
| 724 | # position in tree | ||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | if( $likely ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 727 | my @likely = sort | ||||||||||||||||||||||||||||||||||||||||||
| 728 | { | ||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | return abs($lookup->{nodes}->{$$a}->[1]-$weight) <=> abs($lookup->{nodes}->{$$b}->[1]-$weight); | |||||||||||||||||||||||||||||||||||||||||
| 730 | } @$likely; | ||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | ▶ | if( $node->nodeType == 3 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 733 | # if our comparison is among text nodes, let's go the extra mile and | ||||||||||||||||||||||||||||||||||||||||||
| 734 | # see if there is a direct match first | ||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | my $text = $node->textContent(); | |||||||||||||||||||||||||||||||||||||||||
| 736 | # generally speaking white-space is insignificant in XML, so at least | ||||||||||||||||||||||||||||||||||||||||||
| 737 | # for matching purposes, we want to consider it as such | ||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | $self->_debug( "comparing text nodes: $text" ); | |||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | foreach my $c ( @likely ) { | |||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | my $compare = $c->textContent(); | |||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | $compare =~ s/\s*$//; | |||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | $compare =~ s/^\s*//; | |||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | $self->_debug( " => $compare" ); | |||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | ▶ | if( $compare eq $text ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | $candidate = $c; | |||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | $lookup->{nodes}->{$$candidate}->[0] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | while ( !$candidate ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 753 | # we use pop until we have criteria, so that we at least preserve order | ||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | $candidate = shift @likely; | |||||||||||||||||||||||||||||||||||||||||
| 755 | # gotta catch the case of not having anything in the array | ||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | ▶ | last unless( $candidate ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | if( ! $lookup->{nodes}->{$$candidate} || | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$lookup->{"nodes"}{$$candidate} and $lookup->{"nodes"}{$$candidate}[0]
MC/DC0%0/2
$lookup->{"nodes"}{$$candidate} and $lookup->{"nodes"}{$$candidate}[0]
$lookup->{"nodes"}{$$candidate}
$lookup->{"nodes"}{$$candidate}[0]
Truth table0%0/3
A and B
A= $lookup->{"nodes"}{$$candidate}B= $lookup->{"nodes"}{$$candidate}[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 758 | ! $lookup->{nodes}->{$$candidate}->[0] ) { | ||||||||||||||||||||||||||||||||||||||||||
| 759 | # the node is no longer in the node set with a hashvalue, | ||||||||||||||||||||||||||||||||||||||||||
| 760 | # i.e. it's been matched already | ||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | $self->_debug( " WTF!! this candidate's already been matched" ); | |||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | undef $candidate; | |||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||
| 764 | } | ||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | ▶ | if( $candidate ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 769 | # got a match on this subtree, need to remove the children from the set of | ||||||||||||||||||||||||||||||||||||||||||
| 770 | # matchable nodes | ||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | $self->_propagateMatch( $node,$candidate, $match_type ); | |||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||
| 773 | # we will still have to check the nodes and children for | ||||||||||||||||||||||||||||||||||||||||||
| 774 | # attribute and content changes | ||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||
| 776 | # need to match as many parent nodes by structure as possible | ||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | $self->_matchParents( $node, $candidate ); | |||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | # _matchParents does the bottom up portion of our match propagation, | ||||||||||||||||||||||||||||||||||||||||||
| 780 | # but for better quality diffgrams we need to also do the lazy down | ||||||||||||||||||||||||||||||||||||||||||
| 781 | # where we consider our siblings and match them by structure, in case | ||||||||||||||||||||||||||||||||||||||||||
| 782 | # they don't match by hash.. But that's for the future | ||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||
| 785 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | $self->_debug( "no match, adding children to queue" ); | |||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | push( @queue, $node->childNodes() ); | |||||||||||||||||||||||||||||||||||||||||
| 788 | my @sorted = | ||||||||||||||||||||||||||||||||||||||||||
| 789 | sort { | ||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | $newlookup->{nodes}->{$$b}->[1] <=> $newlookup->{nodes}->{$$a}->[1] | |||||||||||||||||||||||||||||||||||||||||
| 791 | } @queue; | ||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | @queue = @sorted; | |||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||
| 799 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | =head2 _propagateMatch | ||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||
| 803 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 804 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | sub _propagateMatch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_propagateMatch: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | my $new = shift; | |||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | my $old = shift; | |||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | my $match_type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | my $lookup = $self->{old}->{lookup}; | |||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | my $newlookup = $self->{new}->{lookup}; | |||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | my $id = $lookup->{nodes}->{$$old}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | $self->_debug( " propagate xvcs:id: $id" ); | |||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | $self->{MATCH_COUNT}->{$match_type}++; | |||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | ▶ | if( $old->nodeType == 3 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | $self->_debug( $old->textContent." => ".$new->textContent ); | |||||||||||||||||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | ▶ | if( $old->nodeType == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | $new->setAttribute('xvcs:id',$id); | |||||||||||||||||||||||||||||||||||||||||
| 823 | } | ||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||
| 825 | # not sure if we need this guy | ||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | $newlookup->{id}->{$id} = $new; | |||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||
| 828 | # register the ID of the node | ||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | $newlookup->{nodes}->{$$new}->[2] = $id; | |||||||||||||||||||||||||||||||||||||||||
| 830 | # wipe hash of the new node, so we can't match it again (prolly not needed) | ||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | $newlookup->{nodes}->{$$new}->[0] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 832 | # wipe hash of the old node, so we can't match it again | ||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | $lookup->{nodes}->{$$old}->[0] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||
| 835 | # register the nodes as matched so we know not to try to add/delete them | ||||||||||||||||||||||||||||||||||||||||||
| 836 | # and we map the old to the new for later update/move analysis | ||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | $lookup->{match}->{$$old} = $new; | |||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | $lookup->{match_type}->{$$old} = $match_type;#STRUCTURE_MATCH; | |||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | $newlookup->{match_type}->{$$new} = $match_type;#STRUCTURE_MATCH; | |||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||
| 841 | # propagate to children | ||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | my(@new) = $new->childNodes(); | |||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | my(@old) = $old->childNodes(); | |||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | ▶ | while( my $cnew = shift @new ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | my $cold = shift @old; | |||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | $self->_propagateMatch( $cnew,$cold,$match_type ); | |||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 850 | } | ||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||
| 854 | =head2 _matchParents | ||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||
| 856 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 857 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | ▶ | sub _matchParents { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_matchParents: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | my $new = shift; | |||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | my $old = shift; | |||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | my $match = 1; | |||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | my $lookup = $self->{old}->{lookup}; | |||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | my $newlookup = $self->{new}->{lookup}; | |||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | ▶ | while ( $match ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | my $oldparent = $old->parentNode(); | |||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | my $newparent = $new->parentNode(); | |||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||
| 870 | # we check for XML::LibXML::Document to make sure we haven't | ||||||||||||||||||||||||||||||||||||||||||
| 871 | # reached the root | ||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | ▶ | if ( ref $oldparent ne 'XML::LibXML::Document' && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $oldparent ne "XML::LibXML::Document" and ref $newparent ne "XML::LibXML::Document" and $oldparent->nodeName eq $newparent->nodeName
ref $oldparent ne "XML::LibXML::Document" and ref $newparent ne "XML::LibXML::Document"
MC/DC0%0/3
ref $oldparent ne "XML::LibXML::Document" and ref $newparent ne "XML::LibXML::Document" and $oldparent->nodeName eq $newparent->nodeName
ref $oldparent ne "XML::LibXML::Document"
ref $newparent ne "XML::LibXML::Document"
$oldparent->nodeName eq $newparent->nodeName
Truth table0%0/4
A and B and C
A= ref $oldparent ne "XML::LibXML::Document"B= ref $newparent ne "XML::LibXML::Document"C= $oldparent->nodeName eq $newparent->nodeName
| |||||||||||||||||||||||||||||||||||||||||||
| 873 | ref $newparent ne 'XML::LibXML::Document' && | ||||||||||||||||||||||||||||||||||||||||||
| 874 | $oldparent->nodeName eq $newparent->nodeName() ) { | ||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | $self->_debug( " branch matched parents" ); | |||||||||||||||||||||||||||||||||||||||||
| 876 | # register the nodes as matched so we know not to try to add/delete them | ||||||||||||||||||||||||||||||||||||||||||
| 877 | # and we map the old to the new for later update/move analysis | ||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | $lookup->{match}->{$$oldparent} = $newparent; | |||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | $lookup->{match_type}->{$$oldparent} = BRANCH_MATCH; | |||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | $newlookup->{match_type}->{$$newparent} = BRANCH_MATCH; | |||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||
| 882 | #$newparent->setAttribute('xvcs:match','BRANCH'); | ||||||||||||||||||||||||||||||||||||||||||
| 883 | #$oldparent->setAttribute('xvcs:match','BRANCH'); | ||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | my $id = $lookup->{nodes}->{$$oldparent}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 886 | #my $id = $oldparent->getAttribute('xvcs:id'); | ||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||
| 888 | # not sure if we need this guy | ||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | $newlookup->{id}->{$id} = $newparent; | |||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | $newlookup->{nodes}->{$$newparent}->[2] = $id; | |||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | $newparent->setAttribute('xvcs:id',$id); | |||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||
| 893 | # now do a lazy down matching of our children by position | ||||||||||||||||||||||||||||||||||||||||||
| 894 | #$self->_matchSiblings( $old, $new, PRIOR ); | ||||||||||||||||||||||||||||||||||||||||||
| 895 | #$self->_matchSiblings( $old, $new, NEXT ); | ||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | $old = $oldparent; | |||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | $new = $newparent; | |||||||||||||||||||||||||||||||||||||||||
| 898 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | $match = undef; | |||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||
| 901 | } | ||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 904 | } | ||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||
| 906 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||
| 908 | =head2 _markChanges | ||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||
| 910 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 911 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | ▶ | sub _markChanges { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_markChanges: not called CC=34 SCAR=70.8
| |||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | my $old = shift; | |||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | my $parent = shift; | |||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | my $lookup; | |||||||||||||||||||||||||||||||||||||||||
| 918 | my $match_type; | ||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | my $pid; | |||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||
| 921 | # currently we only look at Element and Text nodes (Attribute nodes | ||||||||||||||||||||||||||||||||||||||||||
| 922 | # we handle as a known sub-element of Element nodes) | ||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | ▶ | next unless( $node->nodeType == 3 || $node->nodeType == 1 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$node->nodeType == 3 or $node->nodeType == 1
MC/DC0%0/2
$node->nodeType == 3 or $node->nodeType == 1
$node->nodeType == 3
$node->nodeType == 1
Truth table0%0/3
A or B
A= $node->nodeType == 3B= $node->nodeType == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||
| 925 | #$self->_debug( "old: $old" ); | ||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | ▶ | if( $old ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | $lookup = $self->{old}->{lookup}; | |||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | $match_type = $lookup->{match_type}->{$$node}; | |||||||||||||||||||||||||||||||||||||||||
| 929 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | $lookup = $self->{new}->{lookup}; | |||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | $match_type = $lookup->{match_type}->{$$node}; | |||||||||||||||||||||||||||||||||||||||||
| 932 | } | ||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | ▶ | if( $parent ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | $pid = $lookup->{nodes}->{$$parent}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 936 | #$self->_debug( "PID:$pid" ); | ||||||||||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | my $p_clone; | |||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | ▶ | if( $parent ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | $p_clone = $self->{clone_lookup}->{$$parent}; | |||||||||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||||||||||
| 943 | # we got a special case, where our node is a match, but the parent is not | ||||||||||||||||||||||||||||||||||||||||||
| 944 | # and our node is pure text. In this case the text gets lost since we | ||||||||||||||||||||||||||||||||||||||||||
| 945 | # don't do pure text node moves. To avoid this, we treat this matched text | ||||||||||||||||||||||||||||||||||||||||||
| 946 | # as non-matching | ||||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | ▶ | if( $node->nodeType == 3 && $match_type && $p_clone ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$node->nodeType == 3 and $match_type and $p_clone
$node->nodeType == 3 and $match_type
MC/DC0%0/3
$node->nodeType == 3 and $match_type and $p_clone
$node->nodeType == 3
$match_type
$p_clone
Truth table0%0/4
A and B and C
A= $node->nodeType == 3B= $match_typeC= $p_clone
| |||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | $match_type = undef; | |||||||||||||||||||||||||||||||||||||||||
| 949 | } | ||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | ▶ | if( !$match_type ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 952 | # we're in add/delete mode | ||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | my $action; | |||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||
| 955 | my $clone; | ||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | ▶ | if( $node->nodeType == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | ▶ | my $doc = ($old)?'old':'new'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | $clone = $self->{$doc}->{doc}->createElement( $node->nodeName ); | |||||||||||||||||||||||||||||||||||||||||
| 959 | } elsif( $node->nodeType == 3 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | $clone = $node->cloneNode(); | |||||||||||||||||||||||||||||||||||||||||
| 961 | } | ||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | ▶ | if( $old ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | $action = DELETE; | |||||||||||||||||||||||||||||||||||||||||
| 965 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | $action = INSERT; | |||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | my $id = ++$self->{ID}; | |||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||
| 969 | # do we really need to track this? | ||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | ▶ | if( $node->nodeType == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | $node->setAttribute('xvcs:id',$id ); | |||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||
| 973 | #$self->_debug( "$lookup->{id}->{$id} = $node" ); | ||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | $lookup->{id}->{$id} = $node; | |||||||||||||||||||||||||||||||||||||||||
| 975 | #$self->_debug( "$lookup->{id}->{$id} = $node" ); | ||||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | $lookup->{nodes}->{$$node}->[2] = $id; | |||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | $self->_debug( "INSERT: $pid:$id" ); | |||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | $lookup->{inserts}->{$$clone} = $id; | |||||||||||||||||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | ▶ | if( $node->nodeType == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | foreach my $attr ( $node->attributes() ) { | |||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | ▶ | next if( $attr->nodeName eq 'xvcs:id' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | $clone->setAttribute($attr->nodeName,$attr->value); | |||||||||||||||||||||||||||||||||||||||||
| 985 | } | ||||||||||||||||||||||||||||||||||||||||||
| 986 | } | ||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | $self->{clone_lookup}->{$$node} = $clone; | |||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | ▶ | if( $p_clone ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | $p_clone->appendChild( $clone ); | |||||||||||||||||||||||||||||||||||||||||
| 992 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | ▶ | my $node_name = ($action == DELETE)?'delete':'insert'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | my $diff = $self->{diffgram}->createElement("xvcs:$node_name"); | |||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | my $id = $lookup->{nodes}->{$$node}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | $self->_registerChange($action,$pid,$diff,$id); | |||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | $diff->appendChild( $clone ); | |||||||||||||||||||||||||||||||||||||||||
| 998 | } | ||||||||||||||||||||||||||||||||||||||||||
| 999 | } elsif( $old ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1000 | # we got a match_type, but we only care about matches, when we are | ||||||||||||||||||||||||||||||||||||||||||
| 1001 | # traversing our own tree | ||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||
| 1003 | # we're in update/move mode | ||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | my $match_node = $self->{old}->{lookup}->{match}->{$$node}; | |||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | my @update; | |||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | ▶ | if($node->nodeType == 3) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1007 | # TEXT node, no more children, no attributes, just text | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | ▶ | if( $match_node->textContent ne $node->textContent) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1009 | # we got a text change... For future efficiency, we should be running | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | # LCS diff on that text as well.. or maybe even just plain old 'diff' | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | my $old = $self->{diffgram}->createElement("xvcs:old-value"); | |||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | my $new = $self->{diffgram}->createElement("xvcs:new-value"); | |||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | $old->appendText( $node->textContent() ); | |||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | $new->appendText( $match_node->textContent() ); | |||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | push(@update,$old,$new); | |||||||||||||||||||||||||||||||||||||||||
| 1016 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1017 | } elsif( $node->nodeType == 1) { | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | ▶ | if( $parent && !$self->{old}->{lookup}->{match_type}->{$$parent} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$parent and not $self->{"old"}{"lookup"}{"match_type"}{$$parent}
MC/DC0%0/2
$parent and not $self->{"old"}{"lookup"}{"match_type"}{$$parent}
$parent
not $self->{"old"}{"lookup"}{"match_type"}{$$parent}
Truth table0%0/3
A and not(B)
A= $parentB= not $self->{"old"}{"lookup"}{"match_type"}{$$parent}
| |||||||||||||||||||||||||||||||||||||||||||
| 1019 | # can only consider moves, if we have a parent | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | # (is that a valid assumption, not just a most likely case assumption?) | ||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||
| 1022 | # if parents aren't matched, we've got a move | ||||||||||||||||||||||||||||||||||||||||||
| 1023 | # there's also the move within a parent scenario, but that's handled by | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | # the change re-org that comes later | ||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | my $diff = $self->{diffgram}->createElement("xvcs:move"); | |||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | my $id = $lookup->{nodes}->{$$node}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | my $id2 = $self->{new}->{lookup}->{nodes}->{$$match_node}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | my $m_parent = $match_node->parentNode(); | |||||||||||||||||||||||||||||||||||||||||
| 1029 | 0 | my $m_pid = $self->{new}->{lookup}->{nodes}->{$$m_parent}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | $self->_debug( "MOVE: $pid:$id ?= $m_pid:$id2" ); | |||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | $self->_registerChange(TREE_MOVE,$pid,$diff,$id,$m_pid); | |||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||
| 1035 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1036 | # parent's match, but what about position? | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | my $position = $lookup->{nodes}->{$$node}->[3]; | |||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | my $match_position = $self->{new}->{lookup}->{nodes}->{$$match_node}->[3]; | |||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | ▶ | if( $position != $match_position ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | my $id2 = $self->{new}->{lookup}->{nodes}->{$$match_node}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | my $id = $lookup->{nodes}->{$$node}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | $self->_debug( "position: $id/$position ?= $id2/$match_position" ); | |||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | $self->_registerChange(LOCAL_MOVE,$pid); | |||||||||||||||||||||||||||||||||||||||||
| 1044 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1045 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||
| 1047 | # compare attributes | ||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | my %new = map { $_->nodeName() => $_->value } $match_node->attributes(); | |||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | foreach my $attr ( $node->attributes() ) { | |||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | my $name = $attr->nodeName(); | |||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | my $value = $attr->value(); | |||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | ▶ | if( defined $new{$name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1053 | # got the attribute | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | ▶ | if( $value eq $new{$name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1055 | # same value too, leave it alone | ||||||||||||||||||||||||||||||||||||||||||
| 1056 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1057 | # got an attribute change | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | my $diff = $self->{diffgram}->createElement("xvcs:attr-update"); | |||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | $diff->setAttribute('name',$name); | |||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | $diff->setAttribute('old-value',$value); | |||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | $diff->setAttribute('new-value',$new{$name}); | |||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | push(@update,$diff); | |||||||||||||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1064 | # we're done with this one | ||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | delete $new{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 1066 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1067 | # attribute delete | ||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | my $diff = $self->{diffgram}->createElement("xvcs:attr-delete"); | |||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | $diff->setAttribute('name',$name); | |||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | $diff->setAttribute('value',$value); | |||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | push(@update,$diff); | |||||||||||||||||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | ▶ | while(my($name,$value) = each %new ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1075 | # got some attribute adds | ||||||||||||||||||||||||||||||||||||||||||
| 1076 | 0 | my $diff = $self->{diffgram}->createElement("xvcs:attr-insert"); | |||||||||||||||||||||||||||||||||||||||||
| 1077 | 0 | $diff->setAttribute('name',$name); | |||||||||||||||||||||||||||||||||||||||||
| 1078 | 0 | $diff->setAttribute('value',$value); | |||||||||||||||||||||||||||||||||||||||||
| 1079 | 0 | push(@update,$diff); | |||||||||||||||||||||||||||||||||||||||||
| 1080 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1081 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | 0 | ▶ | if( @update ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1083 | # updates do not affect the structure and an element could have | ||||||||||||||||||||||||||||||||||||||||||
| 1084 | # an update and then a structure changing action, so we go | ||||||||||||||||||||||||||||||||||||||||||
| 1085 | # ahead and add the updates to the diffgram now, so they don't get | ||||||||||||||||||||||||||||||||||||||||||
| 1086 | # in the way of re-ordering the actions later | ||||||||||||||||||||||||||||||||||||||||||
| 1087 | 0 | my $diff = $self->{diffgram}->createElement("xvcs:update"); | |||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | my $id = $lookup->{nodes}->{$$node}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||
| 1090 | 0 | foreach my $update ( @update ) { | |||||||||||||||||||||||||||||||||||||||||
| 1091 | 0 | $diff->appendChild($update); | |||||||||||||||||||||||||||||||||||||||||
| 1092 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | $self->_setDiff( $pid, UPDATE,$id,$diff ); | |||||||||||||||||||||||||||||||||||||||||
| 1094 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | foreach my $child ( $node->childNodes() ) { | |||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | $self->_markChanges( $child, $old, $node ); | |||||||||||||||||||||||||||||||||||||||||
| 1099 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||
| 1101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||
| 1103 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||||||||
| 1105 | =head2 _registerChange | ||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||
| 1107 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1108 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 1109 | 0 | ▶ | sub _registerChange { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_registerChange: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1110 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1111 | 0 | my $action = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | my $pid = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | my $diff = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | my $id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | my $m_pid = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | $self->{change_rank}++; | |||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||
| 1119 | 0 | my $ref = $self->{change}->{$pid}; | |||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | ▶ | unless( $ref ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | my $source = $self->{old}->{lookup}->{id}->{$pid}; | |||||||||||||||||||||||||||||||||||||||||
| 1122 | 0 | my $target = $self->{new}->{lookup}->{id}->{$pid}; | |||||||||||||||||||||||||||||||||||||||||
| 1123 | #$self->_debug( "REG\t$action\t$pid\t$source\t$target" ); | ||||||||||||||||||||||||||||||||||||||||||
| 1124 | $ref = $self->{change}->{$pid} = { | ||||||||||||||||||||||||||||||||||||||||||
| 1125 | rank => $self->{change_rank}, | ||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | pid => $pid, | |||||||||||||||||||||||||||||||||||||||||
| 1127 | source => $source, | ||||||||||||||||||||||||||||||||||||||||||
| 1128 | target => $target, | ||||||||||||||||||||||||||||||||||||||||||
| 1129 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1131 | # LOCAL_MOVE just registers the parent as having changes below it, | ||||||||||||||||||||||||||||||||||||||||||
| 1132 | # but not what nodes. The LCS algorithm decides the local moves | ||||||||||||||||||||||||||||||||||||||||||
| 1133 | # so it doesn't pass $diff | ||||||||||||||||||||||||||||||||||||||||||
| 1134 | 0 | ▶ | if( $action == LOCAL_MOVE ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | $ref->{actions}->[LOCAL_MOVE]++; | |||||||||||||||||||||||||||||||||||||||||
| 1136 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1137 | 0 | my $info = [$action,$id,$diff,$m_pid]; | |||||||||||||||||||||||||||||||||||||||||
| 1138 | 0 | $self->{change_registry}->{$id} = $info; | |||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | $self->_debug( "registering change for $id" ); | |||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | push(@{$ref->{actions}->[$action]}, $info ); | |||||||||||||||||||||||||||||||||||||||||
| 1141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1142 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||
| 1145 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||
| 1147 | =head2 _processChange | ||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||
| 1149 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1150 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 1151 | 0 | ▶ | sub _processChange { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_processChange: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1152 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1153 | 0 | my $ref = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1154 | 0 | my $pid = $ref->{pid}; | |||||||||||||||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | $self->_debug( "processing $ref->{pid}" ); | |||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | ▶ | if( $ref->{done} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1159 | #$self->_debug( "already done" ); | ||||||||||||||||||||||||||||||||||||||||||
| 1160 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||||||||||||||||
| 1163 | # process deletes | ||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | ▶ | if( defined $ref->{actions}->[DELETE] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1165 | 0 | foreach my $rec ( reverse @{$ref->{actions}->[DELETE]} ) { | |||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | $self->_debug( "DELETE" ); | |||||||||||||||||||||||||||||||||||||||||
| 1167 | 0 | $self->_setDiff( $pid, @$rec ); | |||||||||||||||||||||||||||||||||||||||||
| 1168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||
| 1171 | # process tree moves | ||||||||||||||||||||||||||||||||||||||||||
| 1172 | 0 | foreach my $rec ( @{$ref->{actions}->[TREE_MOVE]} ) { | |||||||||||||||||||||||||||||||||||||||||
| 1173 | 0 | $self->_debug( "TREE MOVE" ); | |||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | $self->_setDiff( $pid, @$rec ); | |||||||||||||||||||||||||||||||||||||||||
| 1175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||
| 1177 | # process local moves | ||||||||||||||||||||||||||||||||||||||||||
| 1178 | # need to to an LCS diff on the present nodes.. This is a comparison | ||||||||||||||||||||||||||||||||||||||||||
| 1179 | # of the set as it looks post tree move and delete but pre inserts | ||||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | ▶ | if( $ref->{actions}->[LOCAL_MOVE] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | $self->_debug( "LOCAL MOVE" ); | |||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | $self->_local_move( $pid ); | |||||||||||||||||||||||||||||||||||||||||
| 1183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||
| 1185 | # process inserts | ||||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | ▶ | if( defined $ref->{actions}->[INSERT] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1187 | 0 | foreach my $rec ( reverse @{$ref->{actions}->[INSERT]} ) { | |||||||||||||||||||||||||||||||||||||||||
| 1188 | 0 | $self->_debug( "INSERT" ); | |||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | $self->_setDiff( $pid, @$rec ); | |||||||||||||||||||||||||||||||||||||||||
| 1190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | $ref->{done} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||||||||||
| 1196 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1197 | |||||||||||||||||||||||||||||||||||||||||||
| 1198 | =head2 _local_move | ||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||
| 1200 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1201 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 1202 | 0 | ▶ | sub _local_move { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_local_move: not called CC=16 SCAR=56.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1204 | 0 | my $pid = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1205 | 0 | my $n1 = $self->{old}->{lookup}->{id}->{$pid}; | |||||||||||||||||||||||||||||||||||||||||
| 1206 | 0 | my $n2 = $self->{new}->{lookup}->{id}->{$pid}; | |||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | ▶ | if( $n1 && $n2 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$n1 and $n2
MC/DC0%0/2
$n1 and $n2
$n1
$n2
Truth table0%0/3
A and B
A= $n1B= $n2
| |||||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | my @l1; | |||||||||||||||||||||||||||||||||||||||||
| 1210 | my @l2; | ||||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | foreach my $c1 ( $n1->childNodes() ) { | |||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | my $id = $self->{old}->{lookup}->{nodes}->{$$c1}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | push( @l1,$id); | |||||||||||||||||||||||||||||||||||||||||
| 1214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | foreach my $c2 ( $n2->childNodes() ) { | |||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | my $id = $self->{new}->{lookup}->{nodes}->{$$c2}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | ▶ | if( defined $self->{change_registry}->{$id} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | ▶ | if( $self->{change_registry}->{$id}->[2]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1219 | # this change hasn't been applied yet, so it's not part of | ||||||||||||||||||||||||||||||||||||||||||
| 1220 | # our LCS set | ||||||||||||||||||||||||||||||||||||||||||
| 1221 | # this presumes that all updates have already been completed | ||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 1223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1225 | 0 | push( @l2,$id); | |||||||||||||||||||||||||||||||||||||||||
| 1226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1227 | 0 | my $move; | |||||||||||||||||||||||||||||||||||||||||
| 1228 | traverse_sequences( \@l1, \@l2, | ||||||||||||||||||||||||||||||||||||||||||
| 1229 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | ▶ | DISCARD_A => sub { $move->{$l1[$_[0]]}->[0] = $_[0]; }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1231 | 0 | ▶ | DISCARD_B => sub { $move->{$l2[$_[1]]}->[1] = $_[1]; }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1232 | 0 | } ); | |||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | foreach my $id ( sort { $a <=> $b } keys %$move ) { | |||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | my $m_ref = $move->{$id}; | |||||||||||||||||||||||||||||||||||||||||
| 1236 | 0 | ▶ | if( !defined $m_ref->[0] || !defined $m_ref->[1] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $m_ref->[0] and defined $m_ref->[1]
MC/DC0%0/2
defined $m_ref->[0] and defined $m_ref->[1]
defined $m_ref->[0]
defined $m_ref->[1]
Truth table0%0/3
A and B
A= defined $m_ref->[0]B= defined $m_ref->[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 1237 | # both the source and destination need to be defined. | ||||||||||||||||||||||||||||||||||||||||||
| 1238 | # theoretically we should never hit this since our algorithm | ||||||||||||||||||||||||||||||||||||||||||
| 1239 | # should guarantee that local move comparisons go only against | ||||||||||||||||||||||||||||||||||||||||||
| 1240 | # balanced sets | ||||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | $self->_debug( "$id doesn't appear in before and after, so we don't consider it a move" ); | |||||||||||||||||||||||||||||||||||||||||
| 1242 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 1243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1244 | 0 | $self->_debug( "moving $id from $m_ref->[0] to $m_ref->[1]" ); | |||||||||||||||||||||||||||||||||||||||||
| 1245 | |||||||||||||||||||||||||||||||||||||||||||
| 1246 | 0 | my $diff = $self->{diffgram}->createElement("xvcs:move"); | |||||||||||||||||||||||||||||||||||||||||
| 1247 | 0 | my $source_diff = $self->{diffgram}->createElement("xvcs:source"); | |||||||||||||||||||||||||||||||||||||||||
| 1248 | 0 | $diff->appendChild( $source_diff ); | |||||||||||||||||||||||||||||||||||||||||
| 1249 | 0 | my $destination = $self->{new}->{lookup}->{id}->{$id}; | |||||||||||||||||||||||||||||||||||||||||
| 1250 | 0 | my $source = $self->{old}->{lookup}->{id}->{$id}; | |||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||
| 1252 | # since we're adjusting the source tree, we can blindly ask for the | ||||||||||||||||||||||||||||||||||||||||||
| 1253 | # sources previous sibling | ||||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 | my $source_prior = $source->previousSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1255 | # but we do have to check if it's an element node | ||||||||||||||||||||||||||||||||||||||||||
| 1256 | 0 | my $skip = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | while(1) { | |||||||||||||||||||||||||||||||||||||||||
| 1258 | 0 | ▶ | if( defined $source_prior && $source_prior->nodeType != 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $source_prior and $source_prior->nodeType != 1
MC/DC0%0/2
defined $source_prior and $source_prior->nodeType != 1
defined $source_prior
$source_prior->nodeType != 1
Truth table0%0/3
A and B
A= defined $source_priorB= $source_prior->nodeType != 1
| |||||||||||||||||||||||||||||||||||||||||||
| 1259 | # if it's not an element node, make a note of it in the diff and start the | ||||||||||||||||||||||||||||||||||||||||||
| 1260 | # loop over | ||||||||||||||||||||||||||||||||||||||||||
| 1261 | 0 | $self->_debug( "source_prior is not an element node" ); | |||||||||||||||||||||||||||||||||||||||||
| 1262 | 0 | $source_diff->setAttribute('skip',$skip); | |||||||||||||||||||||||||||||||||||||||||
| 1263 | 0 | $skip++; | |||||||||||||||||||||||||||||||||||||||||
| 1264 | 0 | $source_prior = $source_prior->previousSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1265 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1266 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 1267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||
| 1270 | 0 | $self->_attachInstructions( $source_diff, $source, $source_prior, LOCAL_MOVE ); | |||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | my $node_to_move = $self->_applyMoveUnbind( $source_diff ); | |||||||||||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||||||||||
| 1273 | # for the destination, we have to do a while loop, since there are | ||||||||||||||||||||||||||||||||||||||||||
| 1274 | # nodes in there that we don't recognizing as existing yet | ||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | my $destination_prior; | |||||||||||||||||||||||||||||||||||||||||
| 1276 | 0 | my $start = $destination; | |||||||||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||||||||||
| 1278 | 0 | $skip = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1279 | |||||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | while(1) { | |||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | $destination_prior = $start->previousSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1282 | # no node, we bail | ||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 | ▶ | last unless( $destination_prior ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1284 | |||||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | my $prior_id = $self->{new}->{lookup}->{nodes}->{$$destination_prior}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 1286 | 0 | ▶ | if( defined $self->{change_registry}->{$prior_id} && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"change_registry"}{$prior_id} and $self->{"change_registry"}{$prior_id}[2]
MC/DC0%0/2
defined $self->{"change_registry"}{$prior_id} and $self->{"change_registry"}{$prior_id}[2]
defined $self->{"change_registry"}{$prior_id}
$self->{"change_registry"}{$prior_id}[2]
Truth table0%0/3
A and B
A= defined $self->{"change_registry"}{$prior_id}B= $self->{"change_registry"}{$prior_id}[2]
| |||||||||||||||||||||||||||||||||||||||||||
| 1287 | $self->{change_registry}->{$prior_id}->[2] ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1288 | # this change hasn't been applied yet, so it's not part of | ||||||||||||||||||||||||||||||||||||||||||
| 1289 | # our LCS set | ||||||||||||||||||||||||||||||||||||||||||
| 1290 | 0 | $self->_debug( "prior was applied, ignore it" ); | |||||||||||||||||||||||||||||||||||||||||
| 1291 | 0 | $start = $destination_prior; | |||||||||||||||||||||||||||||||||||||||||
| 1292 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 1293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1294 | # we get here, the prior was good, but we need to check if it's a text | ||||||||||||||||||||||||||||||||||||||||||
| 1295 | # node | ||||||||||||||||||||||||||||||||||||||||||
| 1296 | 0 | ▶ | if( $destination_prior->nodeType != 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1297 | # if it's not an element node, make a note of it in the diff and start the | ||||||||||||||||||||||||||||||||||||||||||
| 1298 | # loop over | ||||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | $self->_debug( "prior was text, ignore it" ); | |||||||||||||||||||||||||||||||||||||||||
| 1300 | 0 | $diff->setAttribute('skip',$skip); | |||||||||||||||||||||||||||||||||||||||||
| 1301 | 0 | $skip++; | |||||||||||||||||||||||||||||||||||||||||
| 1302 | 0 | $start = $destination_prior; | |||||||||||||||||||||||||||||||||||||||||
| 1303 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 1304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1305 | # if we get here, we can safely bail from the loop | ||||||||||||||||||||||||||||||||||||||||||
| 1306 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 1307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1308 | 0 | $self->_attachInstructions( $diff, $destination, $destination_prior, LOCAL_MOVE, $id ); | |||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||
| 1310 | 0 | $diff->setAttribute('id',$id); | |||||||||||||||||||||||||||||||||||||||||
| 1311 | |||||||||||||||||||||||||||||||||||||||||||
| 1312 | 0 | $self->_debug( "moved $id" ); | |||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | $self->_debug( $diff->toString(1) ); | |||||||||||||||||||||||||||||||||||||||||
| 1314 | |||||||||||||||||||||||||||||||||||||||||||
| 1315 | 0 | $self->_applyMoveBind( $diff, $node_to_move ); | |||||||||||||||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||||||||||||||||
| 1317 | 0 | $self->{diffroot}->appendChild( $diff ); | |||||||||||||||||||||||||||||||||||||||||
| 1318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1321 | |||||||||||||||||||||||||||||||||||||||||||
| 1322 | |||||||||||||||||||||||||||||||||||||||||||
| 1323 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1324 | |||||||||||||||||||||||||||||||||||||||||||
| 1325 | =head2 _setDiff | ||||||||||||||||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||||||||||||||||
| 1327 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1328 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 1329 | 0 | ▶ | sub _setDiff { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setDiff: not called CC=20 SCAR=60.4
| |||||||||||||||||||||||||||||||||||||||||||
| 1330 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1331 | 0 | my $pid = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1332 | 0 | my $action = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1333 | 0 | my $id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1334 | 0 | my $diff = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1335 | 0 | my $m_pid = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1336 | 0 | my $lookup = $self->{old}->{lookup}; | |||||||||||||||||||||||||||||||||||||||||
| 1337 | 0 | my $source; | |||||||||||||||||||||||||||||||||||||||||
| 1338 | my $node; | ||||||||||||||||||||||||||||||||||||||||||
| 1339 | #$self->_debug( "setting $id ($action) $pid/$m_pid" ); | ||||||||||||||||||||||||||||||||||||||||||
| 1340 | |||||||||||||||||||||||||||||||||||||||||||
| 1341 | 0 | ▶ | if( !$diff ) {#$action == NOOP ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1342 | #$self->_debug( " already set" ); | ||||||||||||||||||||||||||||||||||||||||||
| 1343 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1344 | } elsif( $action == DELETE ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1345 | # process ourselves as a parent first | ||||||||||||||||||||||||||||||||||||||||||
| 1346 | 0 | ▶ | if( $self->{change}->{$id} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1347 | 0 | $self->_debug( " processing children of $id due to delete" ); | |||||||||||||||||||||||||||||||||||||||||
| 1348 | 0 | $self->_processChange( $self->{change}->{$id} ); | |||||||||||||||||||||||||||||||||||||||||
| 1349 | 0 | $self->_debug( " returning from $id" ); | |||||||||||||||||||||||||||||||||||||||||
| 1350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1351 | } elsif( $m_pid ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1352 | # check new parent for processing action before proceeding | ||||||||||||||||||||||||||||||||||||||||||
| 1353 | 0 | ▶ | if( $self->{change_registry}->{$m_pid} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1354 | 0 | $self->_debug( " parent $m_pid needs to be handled" ); | |||||||||||||||||||||||||||||||||||||||||
| 1355 | 0 | $self->_setDiff( $pid, @{$self->{change_registry}->{$m_pid}} ); | |||||||||||||||||||||||||||||||||||||||||
| 1356 | 0 | $self->_debug( " done handling $m_pid" ); | |||||||||||||||||||||||||||||||||||||||||
| 1357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1358 | 0 | $lookup = $self->{new}->{lookup}; | |||||||||||||||||||||||||||||||||||||||||
| 1359 | 0 | $source = $self->{old}->{lookup}->{id}->{$id}; | |||||||||||||||||||||||||||||||||||||||||
| 1360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||
| 1362 | 0 | $node = $lookup->{id}->{$id}; | |||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||
| 1364 | 0 | my $prior; | |||||||||||||||||||||||||||||||||||||||||
| 1365 | my $node_to_move; | ||||||||||||||||||||||||||||||||||||||||||
| 1366 | 0 | ▶ | if( $source ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1367 | 0 | my $source_diff = $self->{diffgram}->createElement("xvcs:source"); | |||||||||||||||||||||||||||||||||||||||||
| 1368 | 0 | $diff->appendChild( $source_diff ); | |||||||||||||||||||||||||||||||||||||||||
| 1369 | 0 | my $source_prior = $source->previousSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1370 | # we do have to check if it's a text node | ||||||||||||||||||||||||||||||||||||||||||
| 1371 | 0 | my $skip = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1372 | 0 | while(1) { | |||||||||||||||||||||||||||||||||||||||||
| 1373 | 0 | ▶ | if( defined $source_prior && $source_prior->nodeType != 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $source_prior and $source_prior->nodeType != 1
MC/DC0%0/2
defined $source_prior and $source_prior->nodeType != 1
defined $source_prior
$source_prior->nodeType != 1
Truth table0%0/3
A and B
A= defined $source_priorB= $source_prior->nodeType != 1
| |||||||||||||||||||||||||||||||||||||||||||
| 1374 | # if it's not an element node, make a note of it in the diff | ||||||||||||||||||||||||||||||||||||||||||
| 1375 | 0 | $source_diff->setAttribute('skip',$skip); | |||||||||||||||||||||||||||||||||||||||||
| 1376 | 0 | $skip++; | |||||||||||||||||||||||||||||||||||||||||
| 1377 | 0 | $source_prior = $source_prior->previousSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1378 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1379 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 1380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1382 | |||||||||||||||||||||||||||||||||||||||||||
| 1383 | 0 | $self->_attachInstructions( $source_diff, $source, $source_prior, $action ); | |||||||||||||||||||||||||||||||||||||||||
| 1384 | 0 | $node_to_move = $self->_applyMoveUnbind( $source_diff ); | |||||||||||||||||||||||||||||||||||||||||
| 1385 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||||||||||||||||
| 1387 | 0 | ▶ | if( $action == UPDATE || $action == DELETE ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$action == 4 or $action == 3
MC/DC0%0/2
$action == 4 or $action == 3
$action == 4
$action == 3
Truth table0%0/3
A or B
A= $action == 4B= $action == 3
| |||||||||||||||||||||||||||||||||||||||||||
| 1388 | 0 | $node = $lookup->{id}->{$id}; | |||||||||||||||||||||||||||||||||||||||||
| 1389 | 0 | $prior = $node->previousSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | my $skip = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1391 | 0 | while(1) { | |||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | ▶ | if( defined $prior && $prior->nodeType != 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $prior and $prior->nodeType != 1
MC/DC0%0/2
defined $prior and $prior->nodeType != 1
defined $prior
$prior->nodeType != 1
Truth table0%0/3
A and B
A= defined $priorB= $prior->nodeType != 1
| |||||||||||||||||||||||||||||||||||||||||||
| 1393 | # if it's not an element node, make a note of it in the diff | ||||||||||||||||||||||||||||||||||||||||||
| 1394 | 0 | $diff->setAttribute('skip',$skip); | |||||||||||||||||||||||||||||||||||||||||
| 1395 | 0 | $skip++; | |||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | $prior = $prior->previousSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1397 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1398 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 1399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1400 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1401 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1402 | # INSERTs and MOVE destinations still need to ignore nodes that | ||||||||||||||||||||||||||||||||||||||||||
| 1403 | # don't yet exist in the document being modified | ||||||||||||||||||||||||||||||||||||||||||
| 1404 | 0 | my $skip = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1405 | 0 | my $prior_action; | |||||||||||||||||||||||||||||||||||||||||
| 1406 | 0 | $lookup = $self->{new}->{lookup}; | |||||||||||||||||||||||||||||||||||||||||
| 1407 | 0 | $node = $lookup->{id}->{$id}; | |||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | my $start = $node; | |||||||||||||||||||||||||||||||||||||||||
| 1409 | 0 | while(1) { | |||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | $prior_action = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1411 | 0 | $prior = $start->previousSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1412 | # no node, we bail | ||||||||||||||||||||||||||||||||||||||||||
| 1413 | 0 | ▶ | last unless( $prior ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1414 | |||||||||||||||||||||||||||||||||||||||||||
| 1415 | 0 | my $prior_id = $lookup->{nodes}->{$$prior}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 1416 | 0 | ▶ | if( defined $self->{change_registry}->{$prior_id} && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"change_registry"}{$prior_id} and $self->{"change_registry"}{$prior_id}[2]
MC/DC0%0/2
defined $self->{"change_registry"}{$prior_id} and $self->{"change_registry"}{$prior_id}[2]
defined $self->{"change_registry"}{$prior_id}
$self->{"change_registry"}{$prior_id}[2]
Truth table0%0/3
A and B
A= defined $self->{"change_registry"}{$prior_id}B= $self->{"change_registry"}{$prior_id}[2]
| |||||||||||||||||||||||||||||||||||||||||||
| 1417 | $self->{change_registry}->{$prior_id}->[2] ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1418 | # this change hasn't been applied yet | ||||||||||||||||||||||||||||||||||||||||||
| 1419 | 0 | $prior_action = $self->{change_registry}->{$prior_id}->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 1420 | 0 | ▶ | if( defined $prior_action && $prior_action <= INSERT ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $prior_action and $prior_action <= 2
MC/DC0%0/2
defined $prior_action and $prior_action <= 2
defined $prior_action
$prior_action <= 2
Truth table0%0/3
A and B
A= defined $prior_actionB= $prior_action <= 2
| |||||||||||||||||||||||||||||||||||||||||||
| 1421 | 0 | $start = $prior; | |||||||||||||||||||||||||||||||||||||||||
| 1422 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 1423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1424 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1425 | # we get here, the prior was good, but we need to check if it's | ||||||||||||||||||||||||||||||||||||||||||
| 1426 | # an element node | ||||||||||||||||||||||||||||||||||||||||||
| 1427 | 0 | ▶ | if( $prior->nodeType != 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1428 | # if it's not an element node, make a node of it in the diff and start the | ||||||||||||||||||||||||||||||||||||||||||
| 1429 | # loop over | ||||||||||||||||||||||||||||||||||||||||||
| 1430 | 0 | $diff->setAttribute('skip',$skip); | |||||||||||||||||||||||||||||||||||||||||
| 1431 | 0 | $skip++; | |||||||||||||||||||||||||||||||||||||||||
| 1432 | 0 | $start = $prior; | |||||||||||||||||||||||||||||||||||||||||
| 1433 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 1434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1435 | # if we get here, we can safely bail from the loop | ||||||||||||||||||||||||||||||||||||||||||
| 1436 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 1437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1438 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||||||||||||||||
| 1440 | 0 | $self->_debug( " attaching instructions" ); | |||||||||||||||||||||||||||||||||||||||||
| 1441 | 0 | $self->_attachInstructions( $diff, $node, $prior, $action, $id ); | |||||||||||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||||||||||||
| 1443 | 0 | ▶ | if( $action == TREE_MOVE ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1444 | # move's are special, they have to happen as two separate actions | ||||||||||||||||||||||||||||||||||||||||||
| 1445 | # so we can't just call the appropriate patch method and be done | ||||||||||||||||||||||||||||||||||||||||||
| 1446 | 0 | $self->_debug( " doing bind action of move" ); | |||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | $self->_applyMoveBind( $diff, $node_to_move ); | |||||||||||||||||||||||||||||||||||||||||
| 1448 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1449 | # find the appropriate patch method and let it manipulate ourselves | ||||||||||||||||||||||||||||||||||||||||||
| 1450 | 0 | $self->_debug( " now apply our action" ); | |||||||||||||||||||||||||||||||||||||||||
| 1451 | 0 | $self->_applyAction( $action, $diff ); | |||||||||||||||||||||||||||||||||||||||||
| 1452 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1453 | |||||||||||||||||||||||||||||||||||||||||||
| 1454 | 0 | $self->{diffroot}->appendChild( $diff ); | |||||||||||||||||||||||||||||||||||||||||
| 1455 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1456 | |||||||||||||||||||||||||||||||||||||||||||
| 1457 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1458 | |||||||||||||||||||||||||||||||||||||||||||
| 1459 | =head2 _attachInstructions | ||||||||||||||||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||||||||||||||||
| 1461 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1462 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 1463 | 0 | ▶ | sub _attachInstructions { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_attachInstructions: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||
| 1464 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1465 | 0 | my $diff = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1466 | 0 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1467 | 0 | my $prior = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1468 | 0 | my $action = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1469 | 0 | my $id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1470 | 0 | my $parent = $node->parentNode; | |||||||||||||||||||||||||||||||||||||||||
| 1471 | |||||||||||||||||||||||||||||||||||||||||||
| 1472 | 0 | ▶ | if( $id ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1473 | 0 | $diff->setAttribute('id',$id); | |||||||||||||||||||||||||||||||||||||||||
| 1474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||||||||||||||||
| 1476 | 0 | $self->_debug( $self->{old}->{lookup}->{id}->{12} ); | |||||||||||||||||||||||||||||||||||||||||
| 1477 | 0 | $self->_debug( $self->{old}->{lookup}->{id}->{13} ); | |||||||||||||||||||||||||||||||||||||||||
| 1478 | |||||||||||||||||||||||||||||||||||||||||||
| 1479 | 0 | ▶ | if( $prior ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1480 | 0 | ▶ | if( $action == INSERT || | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$action == 2 or $action <= 1 and $id
$action <= 1 and $id
MC/DC0%0/3
$action == 2 or $action <= 1 and $id
$action == 2
$action <= 1
$id
Truth table0%0/4
A or B and C
A= $action == 2B= $action <= 1C= $id
| |||||||||||||||||||||||||||||||||||||||||||
| 1481 | ( $action <= LOCAL_MOVE && $id ) | ||||||||||||||||||||||||||||||||||||||||||
| 1482 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1483 | # if its an insert or the insert portion of a move | ||||||||||||||||||||||||||||||||||||||||||
| 1484 | # we need to find the matching node in our current document to | ||||||||||||||||||||||||||||||||||||||||||
| 1485 | # apply this to | ||||||||||||||||||||||||||||||||||||||||||
| 1486 | 0 | my $prior_id = $self->{new}->{lookup}->{nodes}->{$$prior}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||
| 1488 | 0 | $prior = $self->{old}->{lookup}->{id}->{$prior_id}; | |||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||
| 1490 | 0 | $self->_debug( "sibling action ($prior_id)" ); | |||||||||||||||||||||||||||||||||||||||||
| 1491 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1492 | |||||||||||||||||||||||||||||||||||||||||||
| 1493 | 0 | $diff->setAttribute('follows',$prior->nodePath()); | |||||||||||||||||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||||||||||||||||
| 1495 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1496 | 0 | ▶ | if( $action == INSERT || | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$action == 2 or $action <= 1 and $id
$action <= 1 and $id
MC/DC0%0/3
$action == 2 or $action <= 1 and $id
$action == 2
$action <= 1
$id
Truth table0%0/4
A or B and C
A= $action == 2B= $action <= 1C= $id
| |||||||||||||||||||||||||||||||||||||||||||
| 1497 | ( $action <= LOCAL_MOVE && $id ) | ||||||||||||||||||||||||||||||||||||||||||
| 1498 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1499 | # if its an insert or the insert portion of a move | ||||||||||||||||||||||||||||||||||||||||||
| 1500 | # we need to find the matching node in our current document to | ||||||||||||||||||||||||||||||||||||||||||
| 1501 | # apply this to | ||||||||||||||||||||||||||||||||||||||||||
| 1502 | 0 | my $pid = $self->{new}->{lookup}->{nodes}->{$$parent}->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 1503 | |||||||||||||||||||||||||||||||||||||||||||
| 1504 | 0 | $parent = $self->{old}->{lookup}->{id}->{$pid}; | |||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||
| 1506 | 0 | $self->_debug( "first child action ($pid)" ); | |||||||||||||||||||||||||||||||||||||||||
| 1507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1508 | |||||||||||||||||||||||||||||||||||||||||||
| 1509 | 0 | $diff->setAttribute('first-child-of',$parent->nodePath()); | |||||||||||||||||||||||||||||||||||||||||
| 1510 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||||||||||||||||
| 1512 | 0 | ▶ | if( $id && defined $self->{change_registry}->{$id} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$id and defined $self->{"change_registry"}{$id}
MC/DC0%0/2
$id and defined $self->{"change_registry"}{$id}
$id
defined $self->{"change_registry"}{$id}
Truth table0%0/3
A and B
A= $idB= defined $self->{"change_registry"}{$id}
| |||||||||||||||||||||||||||||||||||||||||||
| 1513 | 0 | $self->_debug( "marking $id as done" ); | |||||||||||||||||||||||||||||||||||||||||
| 1514 | 0 | $self->{change_registry}->{$id}->[2] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||||||||||||||||
| 1517 | 0 | ▶ | if( $XML::Diff::DEBUG ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1518 | 0 | $self->_debug( "state ---\n".$self->{old}->{root}->toString(1)."\n" ); | |||||||||||||||||||||||||||||||||||||||||
| 1519 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1520 | |||||||||||||||||||||||||||||||||||||||||||
| 1521 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1522 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1523 | |||||||||||||||||||||||||||||||||||||||||||
| 1524 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1525 | |||||||||||||||||||||||||||||||||||||||||||
| 1526 | =head2 _applyAction | ||||||||||||||||||||||||||||||||||||||||||
| 1527 | |||||||||||||||||||||||||||||||||||||||||||
| 1528 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1529 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 1530 | 0 | ▶ | sub _applyAction { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_applyAction: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1531 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1532 | 0 | my $action = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1533 | 0 | my $diff = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1534 | |||||||||||||||||||||||||||||||||||||||||||
| 1535 | 0 | ▶ | if( $action == INSERT ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1536 | 0 | $self->_applyInsert( $diff ); | |||||||||||||||||||||||||||||||||||||||||
| 1537 | } elsif( $action == UPDATE ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1538 | 0 | $self->_applyUpdate( $diff ); | |||||||||||||||||||||||||||||||||||||||||
| 1539 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1540 | 0 | $self->_applyDelete( $diff ); | |||||||||||||||||||||||||||||||||||||||||
| 1541 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1542 | |||||||||||||||||||||||||||||||||||||||||||
| 1543 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1544 | |||||||||||||||||||||||||||||||||||||||||||
| 1545 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1546 | |||||||||||||||||||||||||||||||||||||||||||
| 1547 | =head2 _applyInsert | ||||||||||||||||||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||||||||||||||||
| 1549 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1550 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 1551 | 0 | ▶ | sub _applyInsert { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_applyInsert: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||||||||||||||||
| 1552 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1553 | 0 | my $patch = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1554 | |||||||||||||||||||||||||||||||||||||||||||
| 1555 | 0 | $self->_debug( 'apply insert' ); | |||||||||||||||||||||||||||||||||||||||||
| 1556 | |||||||||||||||||||||||||||||||||||||||||||
| 1557 | 0 | my $follows = $patch->getAttribute('follows'); | |||||||||||||||||||||||||||||||||||||||||
| 1558 | 0 | my $skip = $patch->getAttribute('skip'); | |||||||||||||||||||||||||||||||||||||||||
| 1559 | 0 | my $before; | |||||||||||||||||||||||||||||||||||||||||
| 1560 | my $node ; | ||||||||||||||||||||||||||||||||||||||||||
| 1561 | |||||||||||||||||||||||||||||||||||||||||||
| 1562 | 0 | ▶ | if( $self->{_MODE} == COMPARE ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1563 | # if we're calling this in the compare phase, we gotta do some node swapping | ||||||||||||||||||||||||||||||||||||||||||
| 1564 | # on the patch since we use the nodes object IDs to do lookups on, i.e. the | ||||||||||||||||||||||||||||||||||||||||||
| 1565 | # set attached to the diffgram is the physical one we have to insert, while | ||||||||||||||||||||||||||||||||||||||||||
| 1566 | # the diffgram gest rewritten with a clone | ||||||||||||||||||||||||||||||||||||||||||
| 1567 | 0 | ($node) = $patch->childNodes(); | |||||||||||||||||||||||||||||||||||||||||
| 1568 | 0 | my $clone = $node->cloneNode(1); | |||||||||||||||||||||||||||||||||||||||||
| 1569 | 0 | $patch->removeChild( $node ); | |||||||||||||||||||||||||||||||||||||||||
| 1570 | 0 | $patch->appendChild( $clone ); | |||||||||||||||||||||||||||||||||||||||||
| 1571 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1572 | # in the patch phase we don't have to play the above tricks and can insert | ||||||||||||||||||||||||||||||||||||||||||
| 1573 | # a clone directly | ||||||||||||||||||||||||||||||||||||||||||
| 1574 | 0 | my($child) = $patch->childNodes(); | |||||||||||||||||||||||||||||||||||||||||
| 1575 | 0 | $node = $child->cloneNode(1); | |||||||||||||||||||||||||||||||||||||||||
| 1576 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1577 | |||||||||||||||||||||||||||||||||||||||||||
| 1578 | 0 | $self->_debug( $node->toString(1) ); | |||||||||||||||||||||||||||||||||||||||||
| 1579 | 0 | my $sibling; | |||||||||||||||||||||||||||||||||||||||||
| 1580 | 0 | ▶ | if( !$follows ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1581 | 0 | my $parent_path = $patch->getAttribute('first-child-of'); | |||||||||||||||||||||||||||||||||||||||||
| 1582 | 0 | my($parent) = $self->{old}->{root}->findnodes( $parent_path ); | |||||||||||||||||||||||||||||||||||||||||
| 1583 | 0 | ▶ | return undef unless( defined $parent ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1584 | 0 | $sibling = $parent->firstChild(); | |||||||||||||||||||||||||||||||||||||||||
| 1585 | 0 | $self->_debug( "not follows - sibling: ".$sibling->toString(1) ); | |||||||||||||||||||||||||||||||||||||||||
| 1586 | 0 | ▶ | if( !$sibling ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1587 | 0 | $parent->appendChild( $node ); | |||||||||||||||||||||||||||||||||||||||||
| 1588 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1589 | } elsif( $skip ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1590 | 0 | ▶ | for(my$i=1;$i<$skip;$i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1591 | 0 | $self->_debug( '..skipping node' ); | |||||||||||||||||||||||||||||||||||||||||
| 1592 | 0 | $sibling = $sibling->nextSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1593 | 0 | ▶ | return undef unless( defined $sibling ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1594 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1595 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1596 | # we really are the first child, so we need to do an insert before | ||||||||||||||||||||||||||||||||||||||||||
| 1597 | 0 | $before = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1598 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1599 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1600 | 0 | ($sibling) = $self->{old}->{root}->findnodes( $follows ); | |||||||||||||||||||||||||||||||||||||||||
| 1601 | 0 | $self->_debug( "sibling: ".$sibling->toString(1) ); | |||||||||||||||||||||||||||||||||||||||||
| 1602 | 0 | ▶ | return undef unless( defined $sibling ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1603 | 0 | ▶ | if( $skip ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1604 | 0 | ▶ | for(my$i=0;$i<$skip;$i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1605 | 0 | $self->_debug( '..skipping node' ); | |||||||||||||||||||||||||||||||||||||||||
| 1606 | 0 | $sibling = $sibling->nextSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1607 | 0 | ▶ | return undef unless( defined $sibling ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1608 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1609 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1610 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1611 | |||||||||||||||||||||||||||||||||||||||||||
| 1612 | 0 | my $n = $node->nodeName(); | |||||||||||||||||||||||||||||||||||||||||
| 1613 | 0 | my $s = $sibling->nodeName(); | |||||||||||||||||||||||||||||||||||||||||
| 1614 | |||||||||||||||||||||||||||||||||||||||||||
| 1615 | 0 | ▶ | if( $before ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1616 | 0 | $self->_debug( "first child, therefore insert before" ); | |||||||||||||||||||||||||||||||||||||||||
| 1617 | 0 | $sibling->parentNode->insertBefore( $node, $sibling ); | |||||||||||||||||||||||||||||||||||||||||
| 1618 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1619 | 0 | $self->_debug( "insert $n after $s" ); | |||||||||||||||||||||||||||||||||||||||||
| 1620 | 0 | $sibling->parentNode->insertAfter( $node, $sibling ); | |||||||||||||||||||||||||||||||||||||||||
| 1621 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1622 | |||||||||||||||||||||||||||||||||||||||||||
| 1623 | 0 | $self->_debug( "MODE: $self->{_MODE}" ); | |||||||||||||||||||||||||||||||||||||||||
| 1624 | 0 | ▶ | if( $self->{_MODE} == COMPARE ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1625 | # if we're applying in COMPARE node, we need to register this node | ||||||||||||||||||||||||||||||||||||||||||
| 1626 | # in our lookup | ||||||||||||||||||||||||||||||||||||||||||
| 1627 | |||||||||||||||||||||||||||||||||||||||||||
| 1628 | 0 | $self->_debug( "patch:\n".$patch->toString(1) ); | |||||||||||||||||||||||||||||||||||||||||
| 1629 | 0 | $self->_insertRegister( $node ); | |||||||||||||||||||||||||||||||||||||||||
| 1630 | # first get it's ID | ||||||||||||||||||||||||||||||||||||||||||
| 1631 | #my $id = $patch->getAttribute( 'id' ); | ||||||||||||||||||||||||||||||||||||||||||
| 1632 | |||||||||||||||||||||||||||||||||||||||||||
| 1633 | # and now we need to put this node in the lookup | ||||||||||||||||||||||||||||||||||||||||||
| 1634 | #$self->{old}->{lookup}->{id}->{$id} = $node; | ||||||||||||||||||||||||||||||||||||||||||
| 1635 | #$self->{old}->{lookup}->{nodes}->{$$node} = [undef,undef,$id]; | ||||||||||||||||||||||||||||||||||||||||||
| 1636 | |||||||||||||||||||||||||||||||||||||||||||
| 1637 | #$self->_debug( "registering new node $id" ); | ||||||||||||||||||||||||||||||||||||||||||
| 1638 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1639 | |||||||||||||||||||||||||||||||||||||||||||
| 1640 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1641 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1642 | |||||||||||||||||||||||||||||||||||||||||||
| 1643 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||||||||||||||||
| 1645 | =head2 _insertRegister | ||||||||||||||||||||||||||||||||||||||||||
| 1646 | |||||||||||||||||||||||||||||||||||||||||||
| 1647 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1648 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 1649 | 0 | ▶ | sub _insertRegister { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_insertRegister: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1650 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1651 | 0 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1652 | |||||||||||||||||||||||||||||||||||||||||||
| 1653 | 0 | my $id = $self->{new}->{lookup}->{inserts}->{$$node}; | |||||||||||||||||||||||||||||||||||||||||
| 1654 | |||||||||||||||||||||||||||||||||||||||||||
| 1655 | 0 | $self->{old}->{lookup}->{id}->{$id} = $node; | |||||||||||||||||||||||||||||||||||||||||
| 1656 | 0 | $self->{old}->{lookup}->{nodes}->{$$node} = [undef,undef,$id]; | |||||||||||||||||||||||||||||||||||||||||
| 1657 | |||||||||||||||||||||||||||||||||||||||||||
| 1658 | 0 | $self->_debug( "registering new node $id" ); | |||||||||||||||||||||||||||||||||||||||||
| 1659 | 0 | foreach my $child ( $node->childNodes() ) { | |||||||||||||||||||||||||||||||||||||||||
| 1660 | 0 | $self->_insertRegister( $child ); | |||||||||||||||||||||||||||||||||||||||||
| 1661 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||||||||||||||||
| 1664 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1665 | |||||||||||||||||||||||||||||||||||||||||||
| 1666 | =head2 _applyUpdate | ||||||||||||||||||||||||||||||||||||||||||
| 1667 | |||||||||||||||||||||||||||||||||||||||||||
| 1668 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1669 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 1670 | 0 | ▶ | sub _applyUpdate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_applyUpdate: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1671 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1672 | 0 | my $patch = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1673 | |||||||||||||||||||||||||||||||||||||||||||
| 1674 | 0 | $self->_debug( 'apply update' ); | |||||||||||||||||||||||||||||||||||||||||
| 1675 | |||||||||||||||||||||||||||||||||||||||||||
| 1676 | 0 | my $follows = $patch->getAttribute('follows'); | |||||||||||||||||||||||||||||||||||||||||
| 1677 | 0 | my $text = $patch->getAttribute('skip'); | |||||||||||||||||||||||||||||||||||||||||
| 1678 | 0 | my $node; | |||||||||||||||||||||||||||||||||||||||||
| 1679 | 0 | ▶ | if( !$follows ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | my $parent_path = $patch->getAttribute('first-child-of'); | |||||||||||||||||||||||||||||||||||||||||
| 1681 | 0 | my($parent) = $self->{old}->{root}->findnodes( $parent_path ); | |||||||||||||||||||||||||||||||||||||||||
| 1682 | 0 | ▶ | return undef unless( defined $parent ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1683 | 0 | $node = $parent->firstChild(); | |||||||||||||||||||||||||||||||||||||||||
| 1684 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1685 | 0 | my($sibling) = $self->{old}->{root}->findnodes( $follows ); | |||||||||||||||||||||||||||||||||||||||||
| 1686 | 0 | ▶ | return undef unless( defined $sibling ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1687 | 0 | ($node) = $sibling->nextSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1688 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1689 | 0 | ▶ | return undef unless( defined $node ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1690 | 0 | ▶ | if( $patch->getAttribute('skip') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1691 | 0 | $node = $node->nextSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1692 | 0 | ▶ | return undef unless( defined $node ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1693 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1694 | 0 | foreach my $update ( $patch->childNodes() ) { | |||||||||||||||||||||||||||||||||||||||||
| 1695 | 0 | my $name = $update->nodeName(); | |||||||||||||||||||||||||||||||||||||||||
| 1696 | 0 | for( $update->nodeName() ) { | |||||||||||||||||||||||||||||||||||||||||
| 1697 | /xvcs:attr-delete/ && | ||||||||||||||||||||||||||||||||||||||||||
| 1698 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1699 | 0 | $node->removeAttribute( $update->getAttribute('name') ); | |||||||||||||||||||||||||||||||||||||||||
| 1700 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 1701 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1702 | /xvcs:attr-insert/ && | ||||||||||||||||||||||||||||||||||||||||||
| 1703 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1704 | 0 | $node->setAttribute( $update->getAttribute('name'),$update->getAttribute('value') ); | |||||||||||||||||||||||||||||||||||||||||
| 1705 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 1706 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1707 | /xvcs:attr-update/ && | ||||||||||||||||||||||||||||||||||||||||||
| 1708 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1709 | 0 | $node->setAttribute( $update->getAttribute('name'),$update->getAttribute('new-value') ); | |||||||||||||||||||||||||||||||||||||||||
| 1710 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 1711 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1712 | /new-value/ && | ||||||||||||||||||||||||||||||||||||||||||
| 1713 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1714 | 0 | $node->setData( $update->textContent ); | |||||||||||||||||||||||||||||||||||||||||
| 1715 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 1716 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1717 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 1718 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1719 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1720 | |||||||||||||||||||||||||||||||||||||||||||
| 1721 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1722 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1723 | |||||||||||||||||||||||||||||||||||||||||||
| 1724 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1725 | |||||||||||||||||||||||||||||||||||||||||||
| 1726 | =head2 _applyDelete | ||||||||||||||||||||||||||||||||||||||||||
| 1727 | |||||||||||||||||||||||||||||||||||||||||||
| 1728 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1729 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 1730 | 0 | ▶ | sub _applyDelete { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_applyDelete: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 1731 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1732 | 0 | my $patch = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1733 | |||||||||||||||||||||||||||||||||||||||||||
| 1734 | 0 | $self->_debug( 'apply delete' ); | |||||||||||||||||||||||||||||||||||||||||
| 1735 | |||||||||||||||||||||||||||||||||||||||||||
| 1736 | 0 | my $follows = $patch->getAttribute('follows'); | |||||||||||||||||||||||||||||||||||||||||
| 1737 | 0 | my $text = $patch->getAttribute('skip'); | |||||||||||||||||||||||||||||||||||||||||
| 1738 | 0 | my $node; | |||||||||||||||||||||||||||||||||||||||||
| 1739 | 0 | ▶ | if( !$follows ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1740 | 0 | my $parent_path = $patch->getAttribute('first-child-of'); | |||||||||||||||||||||||||||||||||||||||||
| 1741 | 0 | my($parent) = $self->{old}->{root}->findnodes( $parent_path ); | |||||||||||||||||||||||||||||||||||||||||
| 1742 | 0 | ▶ | return undef unless( defined $parent ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1743 | 0 | $node = $parent->firstChild(); | |||||||||||||||||||||||||||||||||||||||||
| 1744 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1745 | 0 | my($sibling) = $self->{old}->{root}->findnodes( $follows ); | |||||||||||||||||||||||||||||||||||||||||
| 1746 | 0 | ▶ | return undef unless( defined $sibling ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1747 | 0 | ($node) = $sibling->nextSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1748 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1749 | 0 | ▶ | return undef unless( defined $node ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1750 | 0 | ▶ | if( $patch->getAttribute('skip') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1751 | 0 | $node = $node->nextSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1752 | 0 | ▶ | return undef unless( defined $node ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1753 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1754 | 0 | my $n = $node->nodeName(); | |||||||||||||||||||||||||||||||||||||||||
| 1755 | #print STDERR "deleting $n\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1756 | #print STDERR $patch->toString(1),"\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1757 | 0 | $node->unbindNode(); | |||||||||||||||||||||||||||||||||||||||||
| 1758 | |||||||||||||||||||||||||||||||||||||||||||
| 1759 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1760 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1761 | |||||||||||||||||||||||||||||||||||||||||||
| 1762 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1763 | |||||||||||||||||||||||||||||||||||||||||||
| 1764 | =head2 _applyMove | ||||||||||||||||||||||||||||||||||||||||||
| 1765 | |||||||||||||||||||||||||||||||||||||||||||
| 1766 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1767 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 1768 | 0 | ▶ | sub _applyMove { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_applyMove: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1769 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1770 | 0 | my $patch = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1771 | 0 | my($source) = $patch->childNodes(); | |||||||||||||||||||||||||||||||||||||||||
| 1772 | |||||||||||||||||||||||||||||||||||||||||||
| 1773 | 0 | $self->_debug( 'apply move' ); | |||||||||||||||||||||||||||||||||||||||||
| 1774 | |||||||||||||||||||||||||||||||||||||||||||
| 1775 | 0 | my $node = $self->_applyMoveUnbind( $source ); | |||||||||||||||||||||||||||||||||||||||||
| 1776 | |||||||||||||||||||||||||||||||||||||||||||
| 1777 | 0 | ▶ | if( defined $node && $self->_applyMoveBind( $patch, $node ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $node and $self->_applyMoveBind($patch, $node)
MC/DC0%0/2
defined $node and $self->_applyMoveBind($patch, $node)
defined $node
$self->_applyMoveBind($patch, $node)
Truth table0%0/3
A and B
A= defined $nodeB= $self->_applyMoveBind($patch, $node)
| |||||||||||||||||||||||||||||||||||||||||||
| 1778 | |||||||||||||||||||||||||||||||||||||||||||
| 1779 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1780 | |||||||||||||||||||||||||||||||||||||||||||
| 1781 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1782 | |||||||||||||||||||||||||||||||||||||||||||
| 1783 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1784 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1785 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1786 | |||||||||||||||||||||||||||||||||||||||||||
| 1787 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1788 | |||||||||||||||||||||||||||||||||||||||||||
| 1789 | =head2 _applyMoveUnbind | ||||||||||||||||||||||||||||||||||||||||||
| 1790 | |||||||||||||||||||||||||||||||||||||||||||
| 1791 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1792 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 1793 | 0 | ▶ | sub _applyMoveUnbind { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_applyMoveUnbind: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 1794 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1795 | 0 | my $source = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1796 | 0 | my $follows = $source->getAttribute('follows'); | |||||||||||||||||||||||||||||||||||||||||
| 1797 | 0 | my $node; | |||||||||||||||||||||||||||||||||||||||||
| 1798 | |||||||||||||||||||||||||||||||||||||||||||
| 1799 | 0 | $self->_debug( ' move unbind' ); | |||||||||||||||||||||||||||||||||||||||||
| 1800 | |||||||||||||||||||||||||||||||||||||||||||
| 1801 | # find node to move | ||||||||||||||||||||||||||||||||||||||||||
| 1802 | 0 | ▶ | if( !$follows ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1803 | 0 | my $parent_path = $source->getAttribute('first-child-of'); | |||||||||||||||||||||||||||||||||||||||||
| 1804 | 0 | my($parent) = $self->{old}->{root}->findnodes( $parent_path ); | |||||||||||||||||||||||||||||||||||||||||
| 1805 | 0 | ▶ | return undef unless( defined $parent ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1806 | 0 | $node = $parent->firstChild; | |||||||||||||||||||||||||||||||||||||||||
| 1807 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1808 | 0 | my($sibling) = $self->{old}->{root}->findnodes( $follows ); | |||||||||||||||||||||||||||||||||||||||||
| 1809 | 0 | ▶ | return undef unless( defined $sibling ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1810 | 0 | ($node) = $sibling->nextSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1811 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1812 | |||||||||||||||||||||||||||||||||||||||||||
| 1813 | 0 | ▶ | return undef unless( defined $node ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1814 | |||||||||||||||||||||||||||||||||||||||||||
| 1815 | 0 | ▶ | if( $source->getAttribute('skip') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1816 | 0 | $node = $node->nextSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1817 | 0 | ▶ | return undef unless( defined $node ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1818 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1819 | |||||||||||||||||||||||||||||||||||||||||||
| 1820 | # remove node from tree, so that our Xpaths are expressed properly | ||||||||||||||||||||||||||||||||||||||||||
| 1821 | 0 | $node->unbindNode(); | |||||||||||||||||||||||||||||||||||||||||
| 1822 | 0 | $self->_debug( "unbound:".$node->toString(1) ); | |||||||||||||||||||||||||||||||||||||||||
| 1823 | |||||||||||||||||||||||||||||||||||||||||||
| 1824 | 0 | return $node; | |||||||||||||||||||||||||||||||||||||||||
| 1825 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1826 | |||||||||||||||||||||||||||||||||||||||||||
| 1827 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1828 | |||||||||||||||||||||||||||||||||||||||||||
| 1829 | =head2 _applyMoveBind | ||||||||||||||||||||||||||||||||||||||||||
| 1830 | |||||||||||||||||||||||||||||||||||||||||||
| 1831 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1832 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 1833 | 0 | ▶ | sub _applyMoveBind { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_applyMoveBind: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1834 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1835 | 0 | my $patch = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1836 | 0 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1837 | 0 | my $follows = $patch->getAttribute('follows'); | |||||||||||||||||||||||||||||||||||||||||
| 1838 | 0 | my $text = $patch->getAttribute('skip'); | |||||||||||||||||||||||||||||||||||||||||
| 1839 | 0 | my $sibling; | |||||||||||||||||||||||||||||||||||||||||
| 1840 | |||||||||||||||||||||||||||||||||||||||||||
| 1841 | 0 | $self->_debug( ' move bind' ); | |||||||||||||||||||||||||||||||||||||||||
| 1842 | |||||||||||||||||||||||||||||||||||||||||||
| 1843 | 0 | $self->_debug( $patch->toString(1) ); | |||||||||||||||||||||||||||||||||||||||||
| 1844 | 0 | $self->_debug( $node->toString(1) ); | |||||||||||||||||||||||||||||||||||||||||
| 1845 | |||||||||||||||||||||||||||||||||||||||||||
| 1846 | 0 | my $n = $node->nodeName(); | |||||||||||||||||||||||||||||||||||||||||
| 1847 | |||||||||||||||||||||||||||||||||||||||||||
| 1848 | 0 | ▶ | if( !$follows ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1849 | 0 | my $parent_path = $patch->getAttribute('first-child-of'); | |||||||||||||||||||||||||||||||||||||||||
| 1850 | 0 | $self->_debug( "looking for first child: $parent_path" ); | |||||||||||||||||||||||||||||||||||||||||
| 1851 | #$self->_debug( $self->{old}->{root}->toString(1) ); | ||||||||||||||||||||||||||||||||||||||||||
| 1852 | 0 | my($parent) = $self->{old}->{root}->findnodes( $parent_path ); | |||||||||||||||||||||||||||||||||||||||||
| 1853 | |||||||||||||||||||||||||||||||||||||||||||
| 1854 | 0 | ▶ | return undef unless( defined $parent ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1855 | |||||||||||||||||||||||||||||||||||||||||||
| 1856 | 0 | $sibling = $parent->firstChild(); | |||||||||||||||||||||||||||||||||||||||||
| 1857 | |||||||||||||||||||||||||||||||||||||||||||
| 1858 | 0 | ▶ | if( !$sibling ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1859 | 0 | $parent->appendChild( $node ); | |||||||||||||||||||||||||||||||||||||||||
| 1860 | 0 | my $p = $parent->nodeName(); | |||||||||||||||||||||||||||||||||||||||||
| 1861 | 0 | $self->_debug( "move $n as first child of $p" ); | |||||||||||||||||||||||||||||||||||||||||
| 1862 | |||||||||||||||||||||||||||||||||||||||||||
| 1863 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1864 | |||||||||||||||||||||||||||||||||||||||||||
| 1865 | } elsif( $text ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1866 | # this means we really are the next sibling | ||||||||||||||||||||||||||||||||||||||||||
| 1867 | # so we don't need to do anything further here | ||||||||||||||||||||||||||||||||||||||||||
| 1868 | 0 | $self->_debug( "first child was text:".$sibling->textContent() ); | |||||||||||||||||||||||||||||||||||||||||
| 1869 | |||||||||||||||||||||||||||||||||||||||||||
| 1870 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1871 | # we really are the first child, so we need to do an insert before | ||||||||||||||||||||||||||||||||||||||||||
| 1872 | 0 | $parent->insertBefore( $node, $sibling ); | |||||||||||||||||||||||||||||||||||||||||
| 1873 | 0 | my $s = $sibling->nodeName(); | |||||||||||||||||||||||||||||||||||||||||
| 1874 | 0 | $self->_debug( "move $n before $s" ); | |||||||||||||||||||||||||||||||||||||||||
| 1875 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1876 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1877 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1878 | |||||||||||||||||||||||||||||||||||||||||||
| 1879 | 0 | ($sibling) = $self->{old}->{root}->findnodes( $follows ); | |||||||||||||||||||||||||||||||||||||||||
| 1880 | |||||||||||||||||||||||||||||||||||||||||||
| 1881 | 0 | ▶ | return undef unless( defined $sibling ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1882 | |||||||||||||||||||||||||||||||||||||||||||
| 1883 | # the multi-count after_text is a hack until we can order our | ||||||||||||||||||||||||||||||||||||||||||
| 1884 | # actions properly, since there really can't be two consecutive | ||||||||||||||||||||||||||||||||||||||||||
| 1885 | # text nodes in XML parsed from a file, they're just be read as one | ||||||||||||||||||||||||||||||||||||||||||
| 1886 | # node. | ||||||||||||||||||||||||||||||||||||||||||
| 1887 | 0 | ▶ | while( $text ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1888 | 0 | $sibling = $sibling->nextSibling(); | |||||||||||||||||||||||||||||||||||||||||
| 1889 | |||||||||||||||||||||||||||||||||||||||||||
| 1890 | 0 | ▶ | return undef unless( defined $sibling ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1891 | |||||||||||||||||||||||||||||||||||||||||||
| 1892 | 0 | $text--; | |||||||||||||||||||||||||||||||||||||||||
| 1893 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1894 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1895 | |||||||||||||||||||||||||||||||||||||||||||
| 1896 | 0 | my $s = $sibling->nodeName(); | |||||||||||||||||||||||||||||||||||||||||
| 1897 | |||||||||||||||||||||||||||||||||||||||||||
| 1898 | 0 | $self->_debug( "move $n after $s" ); | |||||||||||||||||||||||||||||||||||||||||
| 1899 | 0 | my $parent = $sibling->parentNode(); | |||||||||||||||||||||||||||||||||||||||||
| 1900 | 0 | $parent->insertAfter( $node, $sibling ); | |||||||||||||||||||||||||||||||||||||||||
| 1901 | |||||||||||||||||||||||||||||||||||||||||||
| 1902 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1903 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1904 | |||||||||||||||||||||||||||||||||||||||||||
| 1905 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1906 | |||||||||||||||||||||||||||||||||||||||||||
| 1907 | =head2 _debug | ||||||||||||||||||||||||||||||||||||||||||
| 1908 | |||||||||||||||||||||||||||||||||||||||||||
| 1909 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1910 | # _________________________________________________________ | ||||||||||||||||||||||||||||||||||||||||||
| 1911 | 0 | ▶ | sub _debug { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_debug: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1912 | 0 | ▶ | return unless $XML::Diff::DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1913 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1914 | 0 | my $msg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1915 | 0 | print STDERR "$msg\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1916 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1917 | |||||||||||||||||||||||||||||||||||||||||||
| 1918 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 1919 | |||||||||||||||||||||||||||||||||||||||||||
| 1920 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 1921 | |||||||||||||||||||||||||||||||||||||||||||
| 1922 | Arne Claassen <sdether@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||
| 1923 | |||||||||||||||||||||||||||||||||||||||||||
| 1924 | =head1 MAINTAINER | ||||||||||||||||||||||||||||||||||||||||||
| 1925 | |||||||||||||||||||||||||||||||||||||||||||
| 1926 | Tim Meadowcroft <timm@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||
| 1927 | |||||||||||||||||||||||||||||||||||||||||||
| 1928 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 1929 | |||||||||||||||||||||||||||||||||||||||||||
| 1930 | 0.05 | ||||||||||||||||||||||||||||||||||||||||||
| 1931 | |||||||||||||||||||||||||||||||||||||||||||
| 1932 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 1933 | |||||||||||||||||||||||||||||||||||||||||||
| 1934 | 2004, 2007 Arne F. Claassen, All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 1935 | |||||||||||||||||||||||||||||||||||||||||||
| 1936 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1937 | |||||||||||||||||||||||||||||||||||||||||||
| 1938 | |||||||||||||||||||||||||||||||||||||||||||
| 1939 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||