Merge

Merge allows you to handle cases where you have modified a file locally on your client and someone else then checks in another version on the server underneath you. In this situation, the changes applied on the server must be merged into the local version before a checkin can take place, otherwise the server changes would be overwritten when you check in your file.

This command has two different, but similar, functions:

  1. Resolve conflicts between the two files

  2. Examine how Fortress automatically resolves the conflicts.

The first case will arise when the you specify Merge Later on the Get Latest Version dialog box, or when an attempt at an automatic merge has failed. When either of these situations happens, select Show Merge to specify how the conflicts should be resolved.

The second will arise when you specify Attempt Automatic Merge on the Get Latest Version dialog box and the automatic merge succeeds. In this case, select Show Merge to examine precisely what was done by the automatic merge.

To activate the Merge window, select Show Merge in the Source menu or from the context menu.

Background

A merge involves four files:

  1. Baseline File – The original version of the file before edits.

  2. Local File – The local working copy.

  3. Repository File – The new version of the file in the repository made by a different user.

  4. Merged File – The file created by merging both the local and the new repository file together, to be checked back into the repository.

A successful merge will replace the local working copy with the merged file. This is true for automated merges that have produced no conflicts as well

If the repository (server) copy is revised again after a local merge has been completed, then the baseline file changes to the version of the file that was merged against locally. This essentially becomes a new merge at that point, and if an automatic merge reveals a conflict based on the new baseline, you must manually resolve them again. If there is no conflict, the results of the automated merge will replace the local working copy.

You have the ability to view a merge that has occurred on the current baseline only. If you do not like how the file was merged, click Undo on the Merge window to revert back to a local file’s pre-merge state.

Merge Window

Selecting Show Merge brings up the merge tool you have specified in the Options. By default, this is SourceGear’s DiffMerge. Documentation for SourceGear DiffMerge is available from within the tool itself. Documentation for others tools is available from the vendor who provides the tool.

Merge Branches

The Merge Branches command allows you to merge changes from any folder in Fortress to any another folder within the same repository. Usually, these are folders that have been branched from each other and modifications have been continuing in one or both of them. At some point, you may want to resolve all differences between the branches, or move all the changes from one folder to another. Note that although the common case is to merge together branches that have a common ancestor, there is no requirement that they be related – any two folders can be merged.

The folder from which changes are to be migrated is called the origin folder, and the folder which changes are to be applied to is called the target folder.

To do this, go to the Tools menu and click Merge Branches. A wizard will come up to lead you through the steps.

The first page of the wizard will explain the steps in this operation. The merge has three phases:

  1. Moves and Shares

  2. Renames

  3. Everything else

The Move and Rename operations are actually committed to the repository as the wizard progresses. The other changes are not committed but are put in the Pending Change Set for your review.

Merge supports the following operations:

  • File modifications

  • File and folder Renames, Moves, Adds and Deletions

  • File and folder Shares. Shares created within the origin are created in the target folder, but are not shared between the origin and the target.

    Shares going into or out of the origin are not shared in the target. Files and folders in the origin that are shared outside the origin will be ignored in the target, but a warning message will be put in the summary page indicating this. Files and folders shared into the origin will be treated as adds, with a warning message saying they are shares, and those items will be yellow in the list.

  • File and folder Share Branch

  • File and folder Copy Branch and Folder Snapshot. These are treated as adds in the target, and not as branches or Snapshots.

The following operations are completely ignored when merging a folder. The changes in the origin will not be applied in the target, and they will not show up in the wizard list:

  • Cloak

  • File Property Change

  • Pin Status

  • File and Folder Label

  • Folder security changes

  • File/folder undelete. Since branches don’t create deleted items in the branch, you can’t undelete a file or folder in the branch that existed in the trunk. You can delete and then undelete a file in the branch, but this won’t have any effect in the trunk unless the file was modified in some other way.

The screens in the Merge Branches wizard are:

Welcome Screen

This screen describes the process the Merge Branches operation will have, and the items the user will need to specify to use the command.

Specify Origin Folder

This screen allows you to select the “origin” folder from which changes are to be migrated into a target folder

Specify Target Folder

This screen allows you to select the “target” folder, which will be modified to contain the changes that have been applied to the origin folder.

Select Changes To Be Merged

This screen allows you to select which changes in the origin folder to apply to the target folder. Select two versions of the folder, and differences between those versions in the origin folder will be applied to the target folder.

The earliest version you choose essentially becomes the baseline version between the origin and target folders. If the target file is different from the baseline version you’ve chosen, then a file merge takes place between the source and target files to resolve the differences, so that both sets of differences will be reflected in the merged target version.

Select the versions by using CTRL and the left mouse button to select exactly two versions.

Settings

This screen allows you to enter the following settings:

  • Attempt Automatic Merge on Individual Files. If checked, Merge Branches will attempt to automatically resolve conflicts in files that have been changed in both the origin and the target folders. If unchecked, any file that needs merged will be added to the Pending Change Set with “Needs Merge” status, and you will need to manually resolve each merge.

  • Comment box (optional). Enter the comment that will be used by default as the change set comment for the changes that result from the Merge Branch operation.

Moves And Shares

The Move/Share page lists all the move and share operations to be performed as part of the merge.

  1. Items which cannot proceed are shown with a red background. For example, if a file was modified in the branch but has been deleted in the trunk.

  2. Items which appear to be harmless are shown with a white background and they are checked by default. For example, renaming a file in the branch which has been unchanged in the trunk is an operation which will proceed by default.

  3. Items which can proceed but may be undesirable are shown with a yellow background. For example, if a file was renamed in the branch but has also been renamed in the trunk (to something else), then this operation will not be checked and will be shown in yellow.

  4. Items which do not need to proceed are shown in blue. These are cases where the trunk is in exactly the state it would be in if the merge were to occur anyway. For example, if a file has been renamed in the branch and has been renamed the same way in the trunk, then nothing needs to be done.

Choose the items that are to be included in the merge by selecting the checkbox next to each item. The move operations will be performed and committed to the repository as the wizard proceeds.

Renames

The Rename page lists all the rename operations in the same manner as the Move/Share list. Choose the items that are to be included in the merge by selecting the checkbox next to each item. The rename operations will be performed and committed to the repository as the wizard proceeds.

Retrieve Files from Server

In order to do the merge branch operation, files are retrieved from the server, so Fortress can compute the differences between the version. The Retrieve Files from Server page shows you the status of the file downloads as they are being downloaded from the server.

Adds, Deletes, Edits

The Adds, Deletes, Edits page lists all adds, deletes and edits in the same manner as the Move list. Choose the items that are to be included in the merge by selecting the checkbox next to each item. These operations will be performed, but will not be immediately committed to the repository. Instead, they will be placed in the Pending Change Set for your review and can be committed once you’ve reviewed the changes. Any files in a Needs Merge status after the Merge Branches will need to have their conflicts resolved before the changes can be committed.

Modify Files

The Modify Files page simply shows you the progress of the merge and when it is completed.

Summary

The Summary page will show you all the operations that were performed and the ones which remain pending.

Binary Files

Merge operations cannot be done on binary files. However, a binary file can have a status of Needs Merged if it was modified locally and then checked out after another user checked in a change to the file. You can overwrite the version in the repository and change the status to Edited by selecting Merge. A warning dialog will appear.

Click Yes and the status of the file becomes Edited and the working file is not touched.

Click on No to cancel the operation. The file will retain the Needs Merged status.