Question & Answer
Question
How do you copy a binary file between branches using cleartool merge -base in IBM Rational ClearCase?
Cause
The Rational ClearCase merge tool is only able to compare and merge text files; binary files cannot be merged as detailed in the following technotes:
- 1123371 - Handling binary files in ClearCase
- 1240740 - New Merge Type Copy feature with ClearCase 7.0
Answer
A binary file can be copied between branches to effectively make it the latest version on the target branch.
- Using the merge command with the -base option specifying the LATEST version on the destination branch will force ClearCase into performing a trivial merge.
- This will copy the data from the source branch onto the destination branch.
- The version on the destination branch will be an exact copy of the version on the test branch in the example below.
Note: This will not merge the two versions, because the merge utility cannot combine binary files.
EXAMPLE
Windows:
- Checkout the target version:
M:\view\VOB\merge_test>cleartool co -nc test2.zip
Checked out "test2.zip" from version "\main\3".
- Use the merge command to copy the binary file to the target branch. This will copy the data from the contributor branch onto the destination branch:
M:\view\VOB\merge_test>cleartool merge -to test2.zip -base test2.zip@@/main/LATEST -ver /main/test/LATEST
The version on the destination branch will now be an exact copy of the version on the contributor branch.
- Checkin the target version to commit the change to the VOB database:
M:\view\VOB\merge_test>ct ci -nc test2.zip
Checked in "test2.zip" version "\main\3".
- Draw a merge arrow between the two versions. As the previous merge command did not draw the merge arrow, the merge arrow needs to be added using the merge -ndata option.
M:\my_view\my_vob\merge_test>cleartool merge
-ndata -to test2.zip -ver /main/test/LATEST
Recorded merge of "test2.zip".
UNIX and Linux:
cleartool pwd
/tags/vobjohn
$ file ping
ping: setuid ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, stripped
LATEST VERSION ON MAIN BRANCH is 1
LATEST VERSION ON TESTING BRANCH IS 1
We would like to have ping@@/main/testing/1 as ping@@/main/1 in this example
1) Describe the versions
- $ cleartool desc -l ping@@/main/1
version "ping@@/main/1"
created 2012-02-27T12:40:10-05:00 by john.john@machinexyz
Element Protection:
User : john : r-s
Group: john : r-x
Other: : r-x
element type: compressed_file
predecessor version: /main/0
$ cleartool desc -l ping@@/main/testing/1
version "ping@@/main/testing/1"
created 2012-02-27T12:41:23-05:00 by john.john@machinexyz
"branch testing"
Element Protection:
User : john : r-s
Group: john : r-x
Other: : r-x
element type: compressed_file
predecessor version: /main/testing/0
2) Diff the versions
- $ diff ping@@/main/1 ping@@/main/testing/1
Binary files ping@@/main/1 and ping@@/main/testing/1 differ
$ md5sum ping@@/main/1
b5928507fd0f510640fc2d503942fb2e ping@@/main/1
$ md5sum ping@@/main/testing/1
70860f53814ec3ed0b1118d0e7e56609 ping@@/main/testing/1
3) "Merge" the binaries
- $ cleartool co ping
Checkout comments for "ping":
.
Checked out "ping" from version "/main/1".
$ cleartool merge -to ping -base ping@@/main/LATEST -ver /main/testing/LATEST
Trivial merge: "ping" is same as base "ping@@/main/LATEST".
Copying "/tags/vobjohn/ping@@/main/testing/1" to output file.
Moved contributor "ping" to "ping.contrib".
Output of merge is in "ping".
$ cleartool ci -nc ping
Checked in "ping" version "/main/2".
$ md5sum ping@@/main/2
70860f53814ec3ed0b1118d0e7e56609 ping@@/main/2
$ md5sum ping@@/main/testing/1
70860f53814ec3ed0b1118d0e7e56609 ping@@/main/testing/1
4) Draw a merge arrow
- $ cleartool merge -ndata -to ping -ver /main/testing/LATEST
Recorded merge of "ping".
cleartool desc -l ping
version "ping@@/main/2"
created 2012-02-27T12:48:40-05:00 by john.john@machinexyz
Element Protection:
User : john : r-s
Group: john : r-x
Other: : r-x
element type: compressed_file
predecessor version: /main/1
Hyperlinks:
Merge@70@/tags/vobjohn <- /tags/vobjohn/ping@@/main/testing/1
$
Review the ClearCase Command Reference Guide on the topic of merge (cleartool man merge) for more information.
Related Information
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21122828