You can predict how the property values and collections in a successor version will change. MergeVersion 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.
You invoke MergeVersion on the successor version of the merge; you pass a reference to the predecessor as an input parameter. You also pass an indication of which version is to be considered the primary version. The primary version is the version whose member values are given priority when there are merge conflicts between the two versions. For each property, MergeVersion uses this rule to resolve merge conflicts:
For each origin collection type whose COLLECTION_MERGEWHOLE flag is set, MergeVersion uses this rule:
For each origin collection type whose COLLECTION_MERGEWHOLE flag is not set, MergeVersion combines the items in the two collections as follows
Note The resulting collection can exclude some items found in the basis object version's collection. For example, if the primary version's collection excludes the item, the resulting collection will exclude the item. Similarly, if the primary version's collection includes an item that is identical to an item in the basis version's collection, but the secondary object version excludes the item, the resulting collection will exclude the item.
For some examples of merge behavior, see Examples of Merging Versions.
When you invoke the MergeVersion method of the IRepositoryObjectVersion interface, Microsoft Repository uses the version graph. 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.
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:
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 corresponding items, 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. Microsoft Repository considers two versioned relationships to differ if any of the following is true:
For example, the following figure shows two items that differ in one respect only; the top item refers to Versions 1 and 3. The corresponding item of the second collection refers to Versions 3 and 5.