Merge Overview

Meta Data Services Programming

Meta Data Services Programming

Merge Overview

To perform a merge operation, you use the MergeVersion method of the RepositoryObjectVersion object.

You can predict how the property values and collections in a successor version will change. The MergeVersion method modifies one object version, the successor, by combining its property values and collections with those of another version, the predecessor. MergeVersion compares the property values and collections of the predecessor version and the successor version to a third version, called the basis version.

MergeVersion does not combine two versions into a third, newly created version. Rather, it merges the property values and collections of one version into another version. After the operation is complete, the modified version becomes a successor of the other version. MergeVersion modifies the version graph accordingly.

Calculating the Basis Version

When you invoke the MergeVersion method, the repository engine uses the version graph to compare version data. The MergeVersion method compares each object version to be merged to a basis version of the same object. The basis version of the two to-be-merged object versions is the most recently created object version that is on the creation path of both the primary object version and the secondary object version of the merge. The creation path of an object version is a path through the version graph leading from the object version directly to Version 1 of the object. Each step of the path leads from an object version to its predecessor creation version.

You can easily follow an object version's creation path backward from it to Version 1 by following the solid arrows in reverse. For example, the version graph in the following figure shows that the creation path of Version 11 goes through these other versions: 9, 5, 4, 2, and 1.

Comparing Collections

As it works, the MergeVersion method must compare collections to each other. It compares each collection in the basis version to its corresponding collection in the primary version and in the secondary version. MergeVersion considers two collections to be different if either of the following is true:

  • One collection contains different objects from the other collection.

  • A corresponding pair of items from the two collections differs from each other.
Comparing Versioned Relationships

The MergeVersion method compares each collection of the basis version of an object to the corresponding collections of the primary version and of the secondary version. As part of these comparisons, the method must compare the versioned relationships of these collections. An item from the basis object version's collection corresponds to an item in the primary or secondary object version's collection if the two items use the same target object. Even if two items correspond, however, they can still differ in important ways. The repository engine considers two versioned relationships to differ if any of the following is true:

  • The collection type is a sequenced collection and the two items have different sequence numbers.

  • The collection type is a naming collection and the two items have different names.

  • The two items refer to different versions of the target object.

  • The two items use a different version of the target object as pinned version.

  • One item has a pinned target object version and the other does not.

For example, the following figure shows two items that differ in one respect only; the top item refers to Versions 1 and Version 3. The corresponding item of the second collection refers to Versions 3 and Version 5.