How does Folder Merge work in SCM Anywhere?

Merge Branches allows you to merge the changes made in one branch of a folder into another branch. Generally, these two branches are generated from a common original version. After a merge, the changes made based on the original version will be merged into the target branch.

This is a three-way merge. The baseline folder is the original version from which the two branches of file are generated. You perform the Merge Branches command on the source version, and the merge result will be in the target branch.

How merge is performed

Before discussing how merge is performed, we first need to understand the concept of 3 parties in merge and 3 types of change.

3 parties in merge:
To perform a merge, 3 parties are needed: base version, source version and target version.

In file branches merge, the version on which Branch was performed is the base version. The modifications made on one branch makes a source version, and modifications made on another branch makes a target version.

3 types of change:

Add. We added new files into the source code;
Delete. We deleted files from the source code;
Change. We changed the content of a file.

Merge steps:

SCM Anywhere compares the source version against the base version to have a list of changes made in the source version;
SCM Anywherecompares the target version against the base version to have a list of changes made in the target version;
SCM Anywhere tries to apply all the changes in the source version to the target version

If there is no conflict, all the changes in the source version are applied to the target version.

If there are any conflicts, visual merge is required. SCM Anywhere shows an interface to let us choose if we want the changes in the source version or the target version.

How Conflict is Detected

If the source version and the target version change the same file, there is a conflict. Example of merge

For example, the content of the base version is:

In one branch, you have made the following changes:
Changed 1.txt
Deleted 2.txt
Added 5.txt
Added folder Sub2

In the another branch, the following changes have been made:
Changed 1.txt
Deleted 3.txt

For the merge result, 5.txt and the folder Sub2 are added into the target. But since both of the versions have changed 1.txt, there is a conflict. Also, the source branch deleted 2.txt while the file still exists in the target. The options is left to the user if to keep/discard this change in the source. When there is a conflict, it is not possible for SCM Anywhere to merge the files automatically and a visual merge is initiated to let us decide which changes will be kept.

2 conflicts:

For the conflict on 1.txt, a file merge will be performed. For the conflict on 2.txt, we can choose whether to discard the change in source or copy it to the target. If we discard the change, 2.txt will not be deleted in the target. And the result in the following figure.