Scenario: Selective merge from a subbranch

The following scenario is an example of a situation that requires selective merging from a subbranch.

The project manager wants to incorporate into new development several lines of code that were added in a particular version (for example, version /main/r1_fix/4 on Linux or the UNIX® system or \main\r1_fix\4 on the Windows® system; see the figure below).

The figure shows a selective merge from a subbranch. Element opt.c has versions 4 to 8 on the main branch and versions 0 to 6 on the r1_fix branch, which is off version 4 on the main branch. Version 4 on r1_fix with the label QA_APPROVED attached is selected to be merged with the checkout of version 8 on main, the target version. A merge arrow starts at version 4 on r1_fix and points to the checkout of version 8 on main.

It is critical that you merge only the lines of code as written in this version: it was used and verified to fix a specific bug that prevents further development on the new project.

Selective merges can be tricky: versions you exclude as contributors to the merge may contain needed revisions. For example, if the function that you added in one version (/main/r1_fix/4 or \main\r1_fix\4) relies on a variable definition that was added in another version (/main/r1_fix/2 or \main\r1_fix\2), you must include version 2 in the merge.

Merging a range of versions

You can also specify a single range of consecutive versions to contribute to the merge. For example, if you need the variable definitions added in one version (for example, /main/r1_fix/2 or \main\r1_fix\2) and the code added in another version (for example, /main/r1_fix/4 or \main\r1_fix\4), you can include versions 2 through 4 in the merge.

Task overview

Merging selective versions from the r1_fix branch involves the following tasks:

  • Preparing a destination view

    The view must select the target version, which in the figure, is opt.c@@/main/8.

  • Finding changes

    Use the Version Tree Browser and the History Browser. In a snapshot view, use the cleartool get command or use the Send To command (on Windows systems only) to see the contents of versions not loaded into your view.

  • Merging changes

    Use the cleartool merge command to merge selected versions or a range of versions.

  • Testing and checking in merge results