When the Merge tool merges two models it by default uses the unique identifiers of the model elements to compare the contributor models with the common ancestor model. If an element with the same unique identifier is found in both the common ancestor model and in one of the contributor models, the Merge tool knows that this element has not been added in the contributor model.
One consequence of matching elements by means of their unique identifiers is that if two developers, that work on different streams, add a class with the same name in the same package, then these classes will have different unique identifiers and hence will be treated as different classes by the Merge tool. However, since Merge knows that it is not allowed in UML to have two classes with the same name in a package, it will report an Add/Add conflict for this case, although strictly this is not a structural conflict but more of a logical conflict.
So when merging you have to choose one of the classes, but not both. But what if the two developers really meant that these two classes should be the same class, based on the fact that they gave the classes the same name? The wanted merge result would then be just a single class which combines the contents of the classes from both contributor models. In situations like this one you need to merge models structurally, without using their unique identifiers as the matching criteria.
Model RealTime supports a feature called Combine Models. It takes two models and performs a structural merge of them, so that one of the models (the source model) is combined into the other model (the target model). The source and target models can be any models and do not need to be versions of the same model. That is, there is no common ancestor model involved when merging models using the Combine Models feature.
Before you combine two models it is a good idea to take a copy of the target model. This is because Combine Models will update the target model directly, giving you no possibility to roll-back the changes unless you have a backup copy.
To use the Combine Models feature select two elements in the Project Explorer that are stored as the root in a model file, right-click and choose the command Combine Models in the context menu. A dialog appears where you can specify which of the selected models that should be the target model:
Unless you are sure about the result of combining the models, it is recommended to leave the "Attempt to combine models automatically" checkbox unmarked. Combining models automatically is similar to an automatic merge; it may be convenient and quick, but you may also get changes in the target model that you didn't expect.
The Combine Models user interface looks slightly different than the Merge user interface:
Combine Models match elements in the source and target models by name and structure rather than using their unique identifiers. In the example shown in the picture above the attribute "a" was added independently in both models. A regular merge would hence treat these as different attributes. But Combine Models consider them to be the same since they have the same name and structure.
To perform the combining of the models you mark all changes in the change list (the upper compartment) that you want to apply to the target model. You can also select the elements in the source model compartment. Finally press the OK button to commit the changes.
Most of the Combine Models user interface is the same as the Compare/Merge user interface. The main difference is the button Show Manual Mappings Pane which is explained in Manual mappings.