Merging
Introduction to merging
When multiple developers or teams work on different features of an application, additional branches can be made within a model for these features. Each feature can be developed separately and, as soon as it is completed, be combined (merged) with the model's origin branch. This way, a new feature can be developed and tested independently from the rest of the model.
Branches
For extensive information, see the Models and branches manual.
1. Create a merge session
When a branch is completed and tested, it can be merged into its origin branch, for example, the MAIN.
First, you need to create a merge session. Here, changes (delta actions) are determined by comparing the situation at the origin point in time vs. the current point in time (i.e., the moment when the merge session started).
menu Models > Merging > tab Merging
Execute the Create merge session
task.
Pop-up for creating a merge session
Select the Model.
Select which branch (Merge from) needs to be merged into another branch (Merge into).
Now, a comparison is made. Any conflicts will be identified, so you can define a solution strategy in the next step. Nothing has been modified yet, you can still return to the previous step.
As long as a merge session is not completed, the branch will get the status 'merging' to indicate that a merge session is pending. This will be visible in both the Model overview screen and the Switch branch task. Modifications in a branch with the status 'merging' may be lost when the merge is executed.
2. Resolve conflicts
menu Models > Merging > tab Conflicts
When the merge session is started, all actions done in the branch that is being merged compared to the origin model version are analyzed. Conflicts will occur when:
- An entity has been inserted in both the origin and the branch.
- An entity has been deleted or updated in both the origin and the branch, or deleted in one and updated in the other branch.
After the conflicts are detected, they can be resolved one by one.
It is also possible to resolve several conflicts simultaneously with the the Resolve conflict task.
This implements the modifications from the branch or the origin.
To resolve a conflict:
For conflicts of the type "Inserted in origin and branch", you can choose not only what to do with the conflict actions but also with the dependent actions.
Resolution Description - Carry out the branch action, including dependent origin actions
- Carry out the origin action, including dependent branch actionsApplies dependent actions and results in (new) conflicts if they are conflicted. - Only carry out branch actions
- Only carry out origin actionsOnly applies the dependent action of the selected branch but not the dependent actions of the other branch. For other types of conflicts:
Resolution Description - Only carry out the branch action
- Only carry out the origin actionOnly choose what to do with the conflict action (not necessary for the dependent action). For example, when the delete action of a table is chosen, the table is no longer available, so column insert or update actions cannot be executed.
Overview of the conflicts
Compare code in an external tool
menu Models > Merging > tab Conflicts
In code conflicts, choosing the branch or the origin is not always possible.
Sometimes part of both need to be used.
The task Compare code becomes available if the code has been changed in both the branch and origin.
Use it to compare and merge changes from both the branch and origin with an external comparison tool (WinMerge or KDiff3). After saving the file in the comparison tool, the merged text is transferred to the pop-up.
By clicking OK, the value is stored with the branch.
A conflict comparison during a merge session
3. Execute a merge session
When all conflicts have been resolved, you can execute a merge session. In this step, only the required changes will be executed:
- Changes in the source ('merge into') will be reversed if they do not need to be merged according to your choice of conflict resolution (if available).
- Then, the changes in the origin ('merge from') will be added.
menu Models > Merging > tab Merging
- Start the Execute merge session
task to perform the actual merge. Or: use the Schedule execute merge session
task. This can be useful, for example, if you want to merge outside working hours.
- When a branch is merged into the origin, this branch will be deactivated after the merge. If you wish to continue working in that branch, uncheck the Deactivate branch box.
After the merge, the branch that was being merged into will have been updated according to the selected conflict solutions.
Undo a merge session
See chapter Revert a branch in the Models and branches manual.