Contenido principal

Resolve Conflicts in Architecture Models Using Three-Way Merge

R2026b

This example shows how to use the System Composer Three-Way Merge Tool to investigate and resolve conflicts in System Composer™ architecture models in a project. You can view and merge the System Composer architecture model differences, including sequence diagram differences, in the resulting report.

The Merge tool automatically merges non-conflicting changes before you open the merge report. This example demonstrates how to:

  • Review the automatic merge choices.

  • Apply your desired edits to the target file.

  • Decide how to resolve any remaining differences.

  • Resolve conflicts in sequence diagram elements such as messages and lifelines.

After you resolve the conflicts, you can commit the resolved architecture model to source control.

Open System Composer Three-Way Merge Tool

In the Project panel, look for conflicted files. The RobotArchitecture file shows a red warning icon in the source control column, which indicates a conflict.

To see a detailed report of conflicts, in the Source Control panel, in the Modified Files section, right-click the RobotArchitecture/RobotArchitecture.slx file and select View Conflicts.

The source Control panel shows a conflict with the Robot Architecture model file.

Review Changes and Conflicts in Architecture Model

The example project, RobotArchitectureProject, is under Git™ source control. When you attempt to merge the changes of a colleague on the main Git branch into your taskBranch, the operation results in conflicts.

To resolve the conflicts using the Three-Way Merge Tool, examine your local file (Mine, in this example, the taskBranch branch), the conflicting revision (Theirs, in this example, the main branch), and the common ancestor of these two files (Base).

  • Theirs — A colleague, working on the main branch, added a new stereotype to the profile, updated the query used in the Component View view, changed the RobotArmSequence sequence diagram message condition, and removed the positionReached message.

  • Mine — You added Simulink® behavior to the Motion component, updated the query used in the Component View view, changed the same sequence diagram message condition, and added a Trajectory Planning lifeline with an executeTrajectory message in the taskBranch branch.

The System Composer Three-Way Merge Tool opens three panes at the top.

  • The Mine pane displays the changes you made. In this example, the pane is called taskBranch.

  • The Theirs pane displays the changes your colleague made. In this example, the pane is called main.

  • The Base pane displays the common ancestor version.

The tool automatically resolves differences when possible and opens a Target pane. The Target pane contains a copy of your changes from the taskBranch branch and automatic merges. Review the automatic merge choices, edit if desired, and decide how to resolve any remaining conflicts.

In this example, to resolve conflicts in the RobotArchitecture file, resolve conflicts in the Component View view and the RobotArmSequence sequence diagram.

The Three-Way Merge Tool shows Mine, Theirs, and Base panes with a summary table of conflicts and automatic merges.

Resolve Conflicts in RobotArchitecture

Examine the Three-Way Merge report for the RobotArchitecture architecture model.

  • The summary table in the bottom right corner shows that the tool automatically merged non-conflicting changes. The table also shows unresolved conflicts in the report that require attention.

  • In the report, the tool colors unresolved conflicts in red. The tool also colors automatically resolved differences with the color of the corresponding revision.

Examine and resolve the first difference that requires attention. The tool selects the first difference when it opens.

  • The tool selects the Component View row. In the Target pane, in the details table, the tool marks the Color and Component Selection Query properties as conflicts.

  • In this example, the report shows that your colleague changed the color to purple, which conflicts with the color you added, green. You can use the provided option buttons next to the difference to choose which color to keep in the target file.

  • After you select an option button, the summary table updates to show fewer unresolved conflicts.

Resolve the conflict with the Component Selection Query property.

  • In this example, the report shows that your colleague changed the query to HasStereotype(IsStereotypeDerivedFrom('CriticalProcess')), which conflicts with the query you added, HasStereotype(IsStereotypeDerivedFrom('simpleProfile.sysComponent')).

  • By default, in the Target pane, the tool selects the change you made in taskBranch. Suppose you want to keep the default selection. In the pane, click the conflict icon in the Component Selection Query row and click Mark as Resolved.

The conflict icon displays a menu that allows the user to mark the conflict as resolved.

  • The tool updates the row color from red to blue to indicate that the target file now contains the taskBranch change.

Before you click Accept & Close, also resolve the sequence diagram conflicts described in the next section.

Resolve Conflicts in Sequence Diagrams

In addition to architecture model conflicts, the merge report shows differences in the RobotArmSequence sequence diagram.

The tool automatically merged the Trajectory Planning lifeline and executeTrajectory message from taskBranch because these additions do not conflict with changes on the other branch. The report highlights these rows in blue. Two conflicts require manual resolution.

Resolve the first sequence diagram conflict. The tool selects the SensorData message row.

  • In this example, the report shows that both branches changed the message condition. Your colleague changed the condition to falling(SensorData.distance1 < 2), which conflicts with the condition you added, rising(SensorData.distance1 > 5).

  • Suppose you want to keep your condition. Click the Mine option button to select your change for the target file.

The merge report shows conflicting message conditions from both branches.

Resolve the second sequence diagram conflict. The tool selects the positionReached message row.

  • In this example, the report shows that your colleague removed the positionReached message between Motion and Sensor. Even though you did not modify this message, the tool flags deletions for manual review.

  • Suppose you want to accept the deletion. Click the Theirs option button to remove the message from the target file.

The merge report shows a message deletion conflict requiring manual review.

After you resolve both conflicts, the summary table updates to show all differences as resolved. You can review and adjust automatic merge choices before saving. Click Accept & Close to save the target file and mark the conflict as resolved in source control.

Perform Last Checks

When you resolve conflicts in model files, the Git status in the Files and Source Control panels now shows the model files as Modified.

Source Control panel showing that the Robot Architecture model file and profile have been modified.

Before you commit the resolved model files to source control, perform a final review by comparing the merge changes against the current branch. Always qualify merged models by verifying simulation results or running tests.

See Also

|

Topics