Merge2

(System Library)

Description: Attempts to apply two different Diff buffers to a single origin buffer.
Returns: Result buffer.
Usage: Script Only.
Function Groups: Configuration Management
Related to: Combine | Diff | Merge
Format: System.Merge2()
Parameters:  
Source
Required. Buffer or stream to be modified .
Diff1
Required. Buffer or stream containing the first set of Diffs for modifying "SourceBuff"
Diff2
Required.Buffer or stream containing the second set of Diffs for modifying "SourceBuff"
pConflict1
Optional, pointer to a dictionary of conflicting records of Diff1
pConflict2
Optional, pointer to a dictionary of conflicting records of Diff2
pDiffStream
Optional, pointer to a stream contains all non-conflicting records from Diff1 and Diff2.
Comments:

Similar to Combine, but without automatic conflict resolution or change priority.

Both Diff buffers must have started from the same origin and that origin must be the one provided. It is assumed that the Diff buffers represent different changes to the same origin.
This function fails if the changes cannot be applied cleanly, without interfering or conflicting with one another. A conflict is defined as any of the following:

  • Two additions occurring at the same location and adding different data.
  • One deletion and one addition where the addition occurs within the range of the deletion.

Information describing the nature of the failure is provided to the fourth and fifth parameters. The sixth parameter is provided with a combined Diff buffer containing all of the changes that did not conflict.

Rules applied to detect conflicts:

1. Both operations delete and overlapping deletes are combined to create a composite delete. If the composite delete conflicts with a subsequent add, all of the constituent deletes of the composite delete are also marked as being conflicts.

2. Both are addition operations. Conflict can only occur at the offset.

  • If additions occur at different offsets then there is no Conflict.
  • If additions occur at the same offset with the same data, then there is no conflict.
  • If additions occur at the same offset, but adding different data then there is a conflict.

3. One operation adds and the other deletes.

  • If addition occurs within the range of the deletion operation then there is a conflict.
  • If addition occurs outside of the range of the deletion operation, then there is no conflict.

When two records are determined to be conflicting based on the previous rules, we need to go through all previously saved records marked #Pending to move them to the conflicting dictionary.

If there are conflicts between the two Diffs, the subroutine returns conflict information, whereas if there are none then the two diffs are simultaneously applied to the source buffer.

This operation is synchronous, the result buffer is returned by the call.

Examples: