Algorithm-Merge
view release on metacpan or search on metacpan
}, $key_generation_function);
=head1 USAGE
This module complements L<Algorithm::Diff|Algorithm::Diff> by
providing three-way merge and diff functions.
In this documentation, the first list to C<diff3>, C<merge>, and
C<traverse_sequences3> is
called the `original' list. The second list is the `left' list. The
third list is the `right' list.
The optional key generation arguments are the same as in
L<Algorithm::Diff|Algorithm::Diff>. See L<Algorithm::Diff> for more
information.
=head2 diff3
Given references to three lists of items, C<diff3> performs a
three-way difference.
This function returns an array of operations describing how the
left and right lists differ from the original list. In scalar
context, this function returns a reference to such an array.
Perhaps an example would be useful.
Given the following three lists,
original: a b c e f h i k
left: a b d e f g i j k
right: a b c d e h i j k
merge: a b d e g i j k
we have the following result from diff3:
[ 'u', 'a', 'a', 'a' ],
[ 'u', 'b', 'b', 'b' ],
[ 'l', 'c', undef, 'c' ],
[ 'r', 'f', 'f', undef ],
[ 'o', 'h', 'g', 'h' ],
[ 'u', 'i', 'i', 'i' ],
[ 'o', undef, 'j', 'j' ],
[ 'u', 'k', 'k', 'k' ]
The first element in each row is the array with the difference:
c - conflict (no two are the same)
l - left is different
o - original is different
r - right is different
u - unchanged
The next three elements are the lists from the original, left,
and right arrays respectively that the row refers to (in the synopsis,
these are C<@ancestor>, C<@a>, and C<@b>, respectively).
=head2 merge
Given references to three lists of items, C<merge> performs a three-way
merge. The C<merge> function uses the C<diff3> function to do most of
the work.
The only callback currently used is C<CONFLICT> which should be a
$trav = traverse_sequences3(\@ancestor, \@a, \@b, {
# callbacks
}, $key_generation_function);
USAGE
This module complements Algorithm::Diff by providing three-way merge and
diff functions.
In this documentation, the first list to "diff3", "merge", and
"traverse_sequences3" is called the `original' list. The second list is
the `left' list. The third list is the `right' list.
The optional key generation arguments are the same as in
Algorithm::Diff. See Algorithm::Diff for more information.
diff3
Given references to three lists of items, "diff3" performs a three-way
difference.
This function returns an array of operations describing how the left and
right lists differ from the original list. In scalar context, this
function returns a reference to such an array.
Perhaps an example would be useful.
Given the following three lists,
original: a b c e f h i k
left: a b d e f g i j k
right: a b c d e h i j k
merge: a b d e g i j k
we have the following result from diff3:
[ 'u', 'a', 'a', 'a' ],
[ 'u', 'b', 'b', 'b' ],
[ 'l', 'c', undef, 'c' ],
[ 'r', 'f', 'f', undef ],
[ 'o', 'h', 'g', 'h' ],
[ 'u', 'i', 'i', 'i' ],
[ 'o', undef, 'j', 'j' ],
[ 'u', 'k', 'k', 'k' ]
The first element in each row is the array with the difference:
c - conflict (no two are the same)
l - left is different
o - original is different
r - right is different
u - unchanged
The next three elements are the lists from the original, left, and right
arrays respectively that the row refers to (in the synopsis, these are
@ancestor, @a, and @b, respectively).
merge
Given references to three lists of items, "merge" performs a three-way
merge. The "merge" function uses the "diff3" function to do most of the
work.
The only callback currently used is "CONFLICT" which should be a
reference to a subroutine that accepts two array references. The first
( run in 0.292 second using v1.01-cache-2.11-cpan-1c8d708658b )