Name : perl-Algorithm-Diff-Apply
| |
Version : 0.2.3
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : 8.65
| Date : 2024-08-05 20:17:18
|
Group : Development/Libraries/Perl
| Source RPM : perl-Algorithm-Diff-Apply-0.2.3-8.65.src.rpm
|
Size : 0.03 MB
| |
Packager : (none)
| |
Summary : Apply one or more Algorithm::Diff diffs
|
Description :
At worst, the user is made to feel superior to the computer. -- R. E. Mullen [1]
This module contains subroutines for applying diffs generated by \'Algorithm::Diff\' to a target array in the hope of regenerating a new array incorporating all the changes described in the diffs into a new merged array.
If two hunks from different diffs happen to affect the same line, conflicts are detected and can be optionally handed off to helper subroutines for resolution.
* apply_diff ARRAY,DIFF
Applies the changes described by a diff to a copy of _ARRAY_, which is then returned. _DIFF_ is a diff generated by \'Algorithm::Diff::diff()\', and _ARRAY_ must be an array of an appropriate length. Both parameters are passed in as references. Neither argument is modified.
In a scalar context, \'apply_diff()\' returns a reference to the permuted copy that\'s generated. In an array context, the permuted copy is returned as an array value.
This version of the algorithm is simpler and quicker than the full-blown plural form, and should be used if you\'re only ever going to be applying one diff at once.
* apply_diffs ARRAY,HASH
* apply_diffs ARRAY,OPTIONS,HASH
Applies more than one diff to a copy of an array at once, manages conflicts, and returns the permuted copy as either a reference or an array depending on context.
_ARRAY_ must be a reference to an array value of an appropriate length. The array behind the passed reference is not permuted.
The _HASH_ parameter contains diffs from different sources, as generated by \'Algorithm::Diff::diff()\'. The diffs are keyed by arbitrary strings which should reflect their source. See DIFF LABELS for details of what these strings might reflect.
_OPTIONS_, if specified, must be a hash reference of option keywords and the corresponding parameters. The following options are recognised:
* Option \"optimisers\" (a.k.a. \"optimizers\")
Reference to an array of conflict optimiser subroutines. Normally \'apply_diffs()\' performs all the optimisations documented in this module; this option can be used to change that. Pass in an empty array to turn off optimisations altogether. See Conflict Optimiser Callbacks for details of how these subs are called.
* Option \"resolver\"
This option can be used to supply a subroutine which will be called when a conflict is detected. See Conflict Resolver Callbacks details of how resolver routines are called.
* Option \"key_generator\"
If the elements in the target arrays and all the diffs cannot be meaningfully compared with plain \"\'eq\'\" - e.g. reference types - then a hashing function can be supplied using this option. See \'Key Generation Callbacks\' below for details.
* mark_conflicts HASH
This is the default resolver callback; see Conflict Optimiser Callbacks for details of its interface. It causes \'apply_diffs()\' to return arrays looking a bit like:
[ AATTpart_before_conflict, \">>>>>> diff1_name\ \", AATTlines_1, # Lines permuted by diff1 (only) \">>>>>> diff2_name\ \" AATTlines_2, # The same lines, as permuted by diff2 \"< < < < < < \ \", AATTpart_after_conflict, ]
Which is probably the right thing to do if your array is going to be printed out one item per line.
* optimise_remove_duplicates HASH
Conflict optimiser: detects identical diff hunks in the conflict block, and removes all but one of each duplicated hunk.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-A/openSUSE_Tumbleweed/noarch |