Merge branches

At some stage during the development you will want to merge the changes made on one branch back into the trunk, or vice versa.

Merge is closely related to Diff. The merge is accomplished by comparing two points (branches or revisions) in the repository and applying the obtained differences to your working copy.

It is a good idea to perform a merge into an unmodified working copy. If you have made changes to your working copy, commit them first. If the merge does not go as you expect, you may want to revert the changes and Revert cannot recover your uncommitted modifications.

The Merge command can be found in the context menu in the Working Copy view. The directory selected when you issued the command will be the result directory of the merge operation.

 

Figure 3.26. The Merge dialog

The Merge dialog

By default the start URL will be the URL of the selected file in the working copy. You can browse the repository and select a start URL and then choose a revision.

If you want to merge a range of revisions, leave the Use 'From' URL checkbox checked and simply choose the end revision. Be careful when using the HEAD revision. It may not refer to the revision you think it does if someone else committed changes.

If you want to merge a different branch uncheck the Use 'From' URL checkbox, browse the repository for the desired branch, and choose a revision.

You can choose to do a Dry run of the Merge operation in order to see what files are affected and how, without modifying the working copy at all. This is very helpful in detecting where conflicts will occur.

You can also perform a Unified diff and obtain the diff patch file without doing a merge in the working copy. The diff file is not always easy to read out of context, but for small scale changes it is sometimes useful.

The target panel of the dialog reminds you the location of the target resource from the working copy where the merge result will be saved and its corresponding repository URL.

Press the Merge button in order for the operation to take place. You will obtain the result in the selected resource from the working copy.

When the merge is completed it's a good idea to look at the result of the merge and see if it meets your expectations. Because merging is sometimes complicated, when there are major changes, conflicts may appear.