IBM Support

About Subtractive Merge

Question & Answer


Question

This technote explains how to undo a merge in cases where the change that needs to be removed is not the latest version when using IBM® Rational® ClearCase®. This functionality allows you to perform a merge that will exclude versions with bad changes on the same branch.

Answer

To undo a merge when the change you need to remove is not the latest one will require a subtractive merge.

A subtractive merge can be performed to exclude or bypass bad versions on a branch without actually removing the bad versions. Cleartool merge using the -delete option will allow a user to merge from the last known good version to a new version on the same branch which excludes the work done in the versions identified as bad versions. This merge must be performed from the command line, it does not create a merge arrow, the arrow can be created manually.

Here is the syntax for the commands:

  • Subtractive merge:
  • cleartool merge -to filename -delete -ver \main\branch\version_number

  • Merge arrow:
  • cleartool merge -ndata -to filename -ver \main\branch\version_number


The -delete option invokes a subtractive merge, which is the opposite of a selective merge.


A selective merge adds to the checked-out version the changes made in one or more other versions. A subtractive merge removes from the checked-out version the changes made in one or more of its predecessors.


The example below is merging from version \main\4 to new version \main\12, excluding work done in versions 5, 6, 7, 8 and 9. The subtractive merge will not modify versions 10 or 11, but the latest version on the branch will be the result of the merge, which in the example is version 12.

  1. First checkout the destination (or target) file version, which in this example is version 11:
    • cleartool co -nc foo.c
      Checked out "foo.c" from version "\main\11".

  2. To undo the changes made in versions 5 - 9 of file foo.c, while retaining all the changes made before version 5 and after version 9, you can issue this command:
    • cleartool merge -to foo.c -delete -ver \main\5 \main\9

  3. Then draw a merge arrow:
    • cleartool merge -ndata -to foo.c -ver \main\4
      Recorded merge of "foo.c".

  4. Verfiy the results of the subtractive merge, while the version is still checked out, then checkin the new version:
    • cleartool ci -nco foo.c
      Checked in "foo.c" version "\main\12".

Refer to the IBM Rational ClearCase Command Reference, under the topics of Removing the contributions of some versions and Scenario: Removing the contributions of some versions or run cleartool man merge.

[{"Product":{"code":"SSSH27","label":"Rational ClearCase"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Merging","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF015","label":"IRIX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"7.0;7.0.1;7.1;7.1.1;7.1.2","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSSH27","label":"Rational ClearCase"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Merging","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
16 June 2018

UID

swg21123001