Daya Bay Reactor Neutrino Experiment TWiki > TWikiMergeDotPm Daya Bay webs:
Public | 中文 | Internal | Help

Log In or Register

Package TWiki::Merge

Support for merging strings

On this page:

StaticMethod merge2 ($arev,$a,$brev,$b,$sep,$session,$info)

Perform a merge of two versions of the same text, using HTML tags to mark conflicts.

The granularity of the merge depends on the setting of $sep. For example, if it is "\\n", a line-by-line merge will be done.

Where conflicts exist, they are marked using HTML <del> and <ins> tags. <del> marks content from $a while <ins> marks content from $b.

Non-conflicting content (insertions from either set) are not marked.

The plugins mergeHandler is called for each merge.

Call it like this:

$newText = TWiki::Merge::merge2(
   $oldrev, $old, $newrev, $new, '.*?\n', $session, $info );

StaticMethod simpleMerge ($a,$b,$sep) -> \@arr

Perform a merge of two versions of the same text, returning an array of strings representing the blocks in the merged context where each string starts with one of "+", "-" or " " depending on whether it is an insertion, a deletion, or just text. Insertions and deletions alway happen in pairs, as text taken in from either version that does not replace text in the other version will simply be accepted.

The granularity of the merge depends on the setting of $sep. For example, if it is "\\n", a line-by-line merge will be done. $sep characters are retained in the outout.

StaticMethod merge3 ($arev,$a,$brev,$b,$crev,$c,$sep,

$session, $info )

Perform a merge of two versions (b and c) of the same text, using HTML <div> tags to mark conflicts. a is the common ancestor.

The granularity of the merge depends on the setting of $sep. For example, if it is ".*?\\n", a line-by-line merge will be done.

Where conflicts exist, they are labeled using the provided revision numbers.

The plugins mergeHandler is called for each merge.

Here's a little picture of a 3-way merge:

a <- ancestor / b c <- revisions \ / d <- merged result, returned.

call it like this:

    my ( $ancestorMeta, $ancestorText ) =
        $store->readTopic( undef, $webName, $topic, $originalrev );
    $newText = TWiki::Merge::merge3(
        $ancestorText, $prevText, $newText,
        $originalrev, $rev, "new",
        '.*?\n' );



Revision: r3 - 2007-01-16 - 12:12:00 - TWikiContributor

Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Daya Bay? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.TWikiMergeDotPm.