ApexSQL Source Control
This article explains what source control conflict is and how to resolve it in ApexSQL Source Control
Conflicts will be detected when the user made a change on an object version which is not the same as the one on the source control repository (the latest version). This is a common occurrence when two developers are working on the same object. The conflict must be resolved before performing commit or get operations. Conflict appears in the Dedicated database development model only.
When the conflict is detected, the Resolve conflict bar appears in the Action center tab:
Conflicts can be avoided if the latest version of an object is pulled from the repository before modification
To resolve conflict in the Action center, users can choose the following options:
- Keep local – Action for an object will be set to Commit to source control . After the Apply button is used to commit changes, a version of an object in a database will overwrite the latest version of an object on source control
- Take from repository – Action for an object will be set on Apply against a database . After the Apply button is used to get changes, the latest version of an object from source control will overwrite a version of an object in a database
- Merge – Choose particular changes from a database, and source control to be applied
By selecting the Merge option, the user can merge script differences line by line with the Built-in merging tool directly from the Action center tab, or to choose one of three 3rd party merging tools which are KDiff3, ExamDiff Pro and Beyond Compare. Merging tool can be selected in the ApexSQL Source Control options under the Action center tab (Built-in tool is set by default):
If one of the 3rd party merging tools is used, SQL Server Management Studio will be disabled (out of focus) while the 3rd party tool is opened
Built-in merging tool
The Built-in merging tool will be initialized inside the Action center tab (below the Differences pane):
If the line exists only on one side, it will be automatically added in the merging pane. Conflicted lines can be resolved by choosing Database (blue arrow) or Repository (red arrow). Additionally, the user can input changes manually. Merging will be completed by clicking the Confirm button, in the upper right section of the Differences pane.
If there are still unresolved conflicts left, notification message will appear:
When KDiff3 opens, the database object script is shown in the upper left pane A (Local), and source control object script is shown in the upper right pane B (Remote). The outcome of a conflict resolution is shown in the Output pane:
Conflicted lines can be resolved by choosing from A (local) or from B (remote) from the context menu in the Output pane. Additionally, the user can input changes manually. Merging will be completed by clicking the Save button (the Save button is disabled until all conflicts are resolved).
The only difference in use, compared to the previous tool, is that ExamDiff Pro has reverse sides for local and remote script panes. The merging process is similar with an addition to combined L/R and R/L buttons in the main menu which represents an option to include both conflicting lines of code from local and remote sources into the same script (L/R – from left script first, R/L – from right script first):
Beyond Compare groups the differences in blocks which means that if there are two or more different lines in a row, choosing from Local (blue arrow) or Remote (pink arrow) in the Merge pane will copy the whole block of differences. Line by line mode can also be activated by clicking in the arrows panel:
Additionally, the user can input changes manually. Merging will be completed by clicking the Save button.
How to apply merged script
When the merging operation is done, the result is a single script that contains both sets of changes. Action of the object will be set to Commit/Apply in the Action center tab:
By clicking the Apply button, the object will be overwritten in both database and source control repository with the merged script.
Q: Are there some SQL Server object types that are not supported for merging?
A: ApexSQL Source Control merging tool supports all SQL object types for merging.
Q: Do any of these 3rd party merging tools comes preinstalled with ApexSQL Source Control?
No, the user has to download any of these tools and installed them manually.
Q: Is there a way to revert changes after merging is confirmed?
Clicking the Refresh button will revert the merge changes and the conflict will be displayed again in the Action center tab. However, if changes are applied, then they cannot be reverted.