Algorithm-Merge
view release on metacpan or search on metacpan
my $keyGen = shift;
my $a_diff = $callbacks->{'A_DIFF'} || sub { };
my $b_diff = $callbacks->{'B_DIFF'} || sub { };
my $c_diff = $callbacks->{'C_DIFF'} || sub { };
my $no_change = $callbacks->{'NO_CHANGE'} || sub { };
my $conflict = $callbacks->{'CONFLICT'} || sub { };
my $b_len = scalar(@{$bdoc});
my $c_len = scalar(@{$cdoc});
my $target_len = $b_len < $c_len ? $b_len : $c_len;
my $bc_different_lengths = $b_len != $c_len;
my(@bdoc_save, @cdoc_save);
# make these into traverse_sequences calls
my($left, $right);
my %diffs;
my $ts_callbacks = {
DISCARD_A => sub { # discard left
push @{$diffs{$left}}, $_[0];
};
@diffs{(AB_A, AB_B)} = ([], []);
$left = AB_A; $right = AB_B;
Algorithm::Diff::traverse_sequences( $adoc, $bdoc, $ts_callbacks, $keyGen, @_);
@diffs{(AC_A, AC_C)} = ([], []);
$left = AC_A; $right = AC_C;
Algorithm::Diff::traverse_sequences( $adoc, $cdoc, $ts_callbacks, $keyGen, @_);
if($bc_different_lengths) {
@diffs{(CB_C, CB_B)} = ([], []);
$left = CB_C; $right = CB_B;
Algorithm::Diff::traverse_sequences( $cdoc, $bdoc, $ts_callbacks, $keyGen, @_);
@diffs{(BC_B, BC_C)} = ([], []);
$left = BC_B; $right = BC_C;
Algorithm::Diff::traverse_sequences( $bdoc, $cdoc, $ts_callbacks, $keyGen, @_);
if(join(",", @{$diffs{&CB_B}}) ne join(",", @{$diffs{&BC_B}}) ||
=back 4
=head1 BUGS
Most assuredly there are bugs. If a pattern similar to the above
example does not work, send it to <jsmith@cpan.org> or report it on
<http://rt.cpan.org/>, the CPAN bug tracker.
L<Algorithm::Diff|Algorithm::Diff>'s implementation of
C<traverse_sequences> may not be symmetric with respect to the input
sequences if the second and third sequence are of different lengths.
Because of this, C<traverse_sequences3> will calculate the diffs of
the second and third sequences as passed and swapped. If the differences
are not the same, it will issue an `Algorithm::Diff::diff is not symmetric
for second and third sequences...' warning. It will try to handle
this, but there may be some cases where it can't.
=head1 SEE ALSO
L<Algorithm::Diff>.
current position. The three arguments are the current positions
within each sequence.
BUGS
Most assuredly there are bugs. If a pattern similar to the above example
does not work, send it to <jsmith@cpan.org> or report it on
<http://rt.cpan.org/>, the CPAN bug tracker.
Algorithm::Diff's implementation of "traverse_sequences" may not be
symmetric with respect to the input sequences if the second and third
sequence are of different lengths. Because of this,
"traverse_sequences3" will calculate the diffs of the second and third
sequences as passed and swapped. If the differences are not the same, it
will issue an `Algorithm::Diff::diff is not symmetric for second and
third sequences...' warning. It will try to handle this, but there may
be some cases where it can't.
SEE ALSO
Algorithm::Diff.
AUTHOR
# `use' statements are after test definition
my $error_message = 'Algorithm::Diff::diff is not symmetric for second and third sequences';
my(@tests, $tests);
BEGIN {
# check sequences of equal length (1 element each)
my @results = (
[ 'u', '', '', '' ],
[ 'r', '', '', 'c' ],
[ 'l', '', 'b', '' ],
[ 'c', '', 'b', 'c' ],
[ 'o', 'a', '', '' ],
[ 'c', 'a', '', 'c' ],
[ 'c', 'a', 'b', '' ],
[ 'c', 'a', 'b', 'c' ],
);
( run in 0.270 second using v1.01-cache-2.11-cpan-65fba6d93b7 )