of 28
8/9/2019 05_scm271_ecc_s03
1/28
Copyright IBM Corp. 2003 3 - 1
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Module 3Merging to and from the Integration Workspace
1
IBM Software Group
Essentials of Rational ClearCaseModule 3: Merging to and from
the Integration Workspace
Topics
Objectives............................................................................................................ 3-2Merging Overview................................................................................................ 3-4Merging Versions in ClearCase............................................................................ 3-10Merging a Single Element from the GUI.............................................................. 3-11Non-Automatic Merges: The Diff Merge Tool ..................................................... 3-14Merging with the Merge Manager ....................................................................... 3-16
8/9/2019 05_scm271_ecc_s03
2/28
Essentials of Rational ClearCase
3 - 2 Copyright IBM Corp. 2003
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Objectives
2
Explain how ClearCase merges versions ofelements
Merge work to and from the integration area
Resolve merge conflicts using the Diff Merge tool
Upon completing this module, you should be able to:
Objectives
8/9/2019 05_scm271_ecc_s03
3/28
Module 3 - Merging to and from the Integration Workspace
Copyright IBM Corp. 2003 3 - 3
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Typical Developer ClearCase Workflow
3
Typical Developer ClearCase Workflow
8/9/2019 05_scm271_ecc_s03
4/28
Essentials of Rational ClearCase
3 - 4 Copyright IBM Corp. 2003
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merging Overview
4
Merging Overview
Merging is the process by which ClearCase propagates
changes from one branch to another
A merge combines the contents of
two or more files or directories into
a new version of a file or directory
After a merge, development can
continue on both branches
Future merges have no restriction
in either frequency or direction
ClearCase includes automated
merge facilities for handling most
merge scenarios
In a parallel development environment, merging is the opposite of branching. Mergingallows you to integrate parallel development.
ClearCase includes automated merge facilities that apply a file merge algorithm tomerging versions. Many merges happen automatically. However, conflicting changes ornon-standard merges require manual intervention.
8/9/2019 05_scm271_ecc_s03
5/28
Module 3 - Merging to and from the Integration Workspace
Copyright IBM Corp. 2003 3 - 5
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Element Types and Merging
5
Element Types and Merging Every file in a VOB is associated with an element type
ClearCase uses element types to categorize and
manage elements
Not all ClearCase element types can be merged
Every file that is stored in a ClearCase VOB is associated with an element type.
ClearCase uses element types to categorize and manage elements: element typesdetermine how a file is stored, retrieved, compared, and merged.
An element gets its type when it is created. ClearCase provides predefined elementtypes for various kinds of file types, or you can create custom element types.
Not all ClearCase element types can be merged.
8/9/2019 05_scm271_ecc_s03
6/28
Essentials of Rational ClearCase
3 - 6 Copyright IBM Corp. 2003
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Integrating Parallel Development: Merging Policies
6
Integrating Parallel Development: Merging Policies
The goal of merging is to integrate parallel development. However, there are manypossible ways to accomplish this goal. Each organization should define a mergingstrategy that works in their environment. Important questions to answer include:
When do we merge? How do we merge? Who performs merges? How often do we merge?
For example, some organizations may encourage developers to merge their own code.Other organizations may designate an integrator who performs all merges as part of thebuild process. In some organizations, developers may be required to merge from theintegration branch to their private development branch before they merge their changesto the integration branch. Or, in other cases, developers may be encouraged to mergetheir private branch changes to the integration branch, then merge from the integrationbranch.
Whatever merging strategy your organization adopts, it is critical to find the right
balance between developer isolation and project integration. In general, it is goodpractice to integrate parallel development early and often. Early integration can alertyou to project design or interface problems. Frequent integrations ensure thatdevelopers keep current with project changes.
8/9/2019 05_scm271_ecc_s03
7/28
Module 3 - Merging to and from the Integration Workspace
Copyright IBM Corp. 2003 3 - 7
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
How ClearCase Merges Files and Directories
7
How ClearCase Merges Files and Directories
ClearCase uses the following files during a merge:
From contributors are one version from each branch you are merging.
The base contributor is the closest common ancestor of the contributors.
The target (to) contributor is the latest version on the branch that will contain theresults of the merge.
The merge result contains the results of the merge. During the merge, it is checked outas a successor to the target contributor. A *.contrib. file in the view temporarily storesthe changes during the merge and can be deleted after the merge is complete.
In some cases, the target contributor is referred to as the to contributor; contributorson other branches are referred to as from contributors.
If all contributors are versions of the same element, ClearCase determines the nearestbase contributor to compare against and enables automatic merging.
If all contributors are NOT versions of the same element, no base contributor is
inferred. Automatic merging is disabled.
8/9/2019 05_scm271_ecc_s03
8/28
Essentials of Rational ClearCase
3 - 8 Copyright IBM Corp. 2003
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merge Algebra
8
Merge Algebra
To merge files and directories, ClearCase takes the following steps:
1. It identifies the base contributor.2. It compares each contributor against the base contributor.
3. It copies any line that is unchanged between the base contributor and any othercontributor to the merge output file.4. For any line that has changed between the base contributor and the other
contributor, ClearCase accepts the change in the contributor. By default,ClearCase copies the change to the merge output file.
5. For any line that has changed between the base contributor and more than oneother contributor, ClearCase requires that you resolve the conflicting difference.
8/9/2019 05_scm271_ecc_s03
9/28
Module 3 - Merging to and from the Integration Workspace
Copyright IBM Corp. 2003 3 - 9
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Types of Merges
9
Types of Merges
The ClearCase Merge tool identifies three types of merges:
Trivial The base contributor and target contributor contain the same data; allchanges are from the from contributor. This can occur when work is done on a
branch, but there are no successor versions after the branch point. For example, work iscompleted on a private branch, but there have been no changes on the integrationbranch. In this case, all the changes in the merge result come from the fromcontributor. This type of merge is sometimes referred to as a whole copy merge.
Non-trivial automatic Thereare changes among the contributors, but there are noconflicting merge points. The Merge tool resolves the merge automatically.
Non-trivial manual Thereare conflicting changes among the contributors. TheMerge tool cannot resolve these automatically. You have to choose between mergecontributors to create the final output.
8/9/2019 05_scm271_ecc_s03
10/28
Essentials of Rational ClearCase
3 - 10 Copyright IBM Corp. 2003
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merging Versions in ClearCase
10
Merging Versions in ClearCase
In ClearCase, you can merge in one of three ways:
Version Tree Browser
ClearCase File Browserand the Merge Manager
Command Line Interface
In ClearCase, you can execute a merge in one of three ways:
Version Tree Browser ClearCase File Browser and Merge Manager
Command line interfaceCLI Procedure
Usage:merge {-to contrib-&-result-pname | -out output-pname}[-base pname][-abort | -qall] [-c comment | -cq | -cqe | -nc] [-insert | -delete]{-version contrib-version-selector... | contrib-pname...}Example:/vobs/Hardware/src% cleartool merge -to hello.chello.c@@/main/r2_int/LATEST********************************> file 2: hello.c@@/main/r2_int/LATESTfrom file 3 [deleting base lines 1-2]
===============Do you want the CHANGE made in file 2? [yes] yesApplying CHANGE from file 2 [line 5]*** Automatic: Applying INSERT from file 3 [line 8]Moved contributor "hello.c" to "hello.c.contrib".Output of merge is in "hello.c".Recorded merge of "hello.c".
NOTE: using the qall option will prompt you to confirm each merge point.
8/9/2019 05_scm271_ecc_s03
11/28
Module 3 - Merging to and from the Integration Workspace
Copyright IBM Corp. 2003 3 - 11
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merging a Single Element from the GUI
11
Merging a Single Element from the GUI
1
On the Version Tree BrowsertoolbarorFile Browser toolbar,click the Merge icon.
Scenario: Forelement hello.c, merge v1 on /pat_2 with v1 on /r2_int
Using the Version Tree Browser, you can only merge one file at a time.
Before you start the merge operation, check out the target contributor. Do not checkout other contributor versions.
8/9/2019 05_scm271_ecc_s03
12/28
Essentials of Rational ClearCase
3 - 12 Copyright IBM Corp. 2003
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merging a Single Element from the GUI (cont.)
12
Merging a Single Element from the GUI (cont.)
2
Select the from version,and then click Ok.
3
Select the to version,and then click Ok.
You are prompted to select the from version and the to version.
8/9/2019 05_scm271_ecc_s03
13/28
Module 3 - Merging to and from the Integration Workspace
Copyright IBM Corp. 2003 3 - 13
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merging a Single Element from the GUI (cont.)
13
Merging a Single Element from the GUI (cont.)
4
ClickYes to attempt to performthe merge automatically.
5
View merge results in the Version TreeBrowser. Notice that the file remainschecked out.
If you click Yes in the ClearCase message box, ClearCase attempts to perform the mergeautomatically.
After the merge, ClearCase leaves the file checked out so that you can test changes. To
complete the merge, check in the file.
8/9/2019 05_scm271_ecc_s03
14/28
Essentials of Rational ClearCase
3 - 14 Copyright IBM Corp. 2003
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Non-Automatic Merges: The Diff Merge Tool
14
Non-Automatic Merges: The Diff Merge Tool
Basecontributor
Merge ResultPanel
From version To version
When there are conflicting changes in the contributors to be merged, ClearCaseperforms a non-automatic merge. ClearCase opens the graphical Diff Merge tool toresolve the differences. The user must decide which contributor to use for each of the
other conflicting diffs.
The Merge Result window displays the merged version. The upper window contains apreview of the selected version. The lower windows display the contents of the basecontributor, the from contributor, and the to or target contributor. The diff mergetool highlights differences among the versions. The toolbar allows you to step, diff bydiff, through the merge. You can accept or override the merge result.
8/9/2019 05_scm271_ecc_s03
15/28
Module 3 - Merging to and from the Integration Workspace
Copyright IBM Corp. 2003 3 - 15
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Using Diff Merge to Resolve Differences
15
Using Diff Merge to Resolve Differences
Navigational Buttons:
Use to move between merge points.
Red arrow:Indicates wherea manual mergeis needed.
Difference Indicators:
Signify that content wasadded, removed, or changed.
Merge Buttons:
Click to move changes from the first,second, or third contributor pane tothe merge results pane.
You merge contributors in Diff Merge by resolving the differences between thosecontributors and saving the results to a merge output file or directory.
When Diff Merge starts, it indicates that it has resolved all non-conflicting differences.
The first unresolved difference is indicated by a vertical blue line at the left edge of thecontributor panes.
8/9/2019 05_scm271_ecc_s03
16/28
Essentials of Rational ClearCase
3 - 16 Copyright IBM Corp. 2003
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merging with the Merge Manager
16
Merging with the Merge Manager
1
Click Versions > Findmerge, andthen select the type of merge toperform.
You can use the Merge Manager when you want to merge multiple elements.
CLI Procedure
Usage:
findmerge {pname...| [pname...] -all | -avobs} [-depth | -nrecurse |-directory] [-follow] [-visible]
Example:
/vobs/Hardware/src% cleartoolfindmerge . -fversion/main/r2_int/LATEST -mergeNeeds Merge "./hello.c" [to /main/r2_int/pat_r2/2 from/main/r2_int/1 base /main/r2_int/0]Checkout comments for this and any additional elements:Merging from Integration to Pats Development areaChecked out "./hello.c" from version "/main/r2_int/pat_r2/2".********************************> file 2: ./hello.c@@/main/r2_int/1
>>> file 3: ./hello.c*********************************** Automatic: Applying INSERT from file 3 [line 8]============Moved contributor "./hello.c" to "./hello.c.contrib".Output of merge is in "./hello.c".Recorded merge of "./hello.c".
8/9/2019 05_scm271_ecc_s03
17/28
Module 3 - Merging to and from the Integration Workspace
Copyright IBM Corp. 2003 3 - 17
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merging with the Merge Manager (cont.)
17
Merging with the Merge Manager (cont.)
2
Select where youwant to merge filesfrom, and then clickOk.
8/9/2019 05_scm271_ecc_s03
18/28
Essentials of Rational ClearCase
3 - 18 Copyright IBM Corp. 2003
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merging with the Merge Manager (cont.)
18
Merging with the Merge Manager (cont.)
3
To start a newsession, click New.
In complex development environments that involve a large number of source files andfrequent branching, integrating parallel development can be challenging.
ClearCase includes the Merge Manager, a graphical tool that automates the processes of
gathering information for a merge, starting a merge, and tracking a merge. It can alsosave and retrieve the state of a merge for a set of elements.
8/9/2019 05_scm271_ecc_s03
19/28
Module 3 - Merging to and from the Integration Workspace
Copyright IBM Corp. 2003 3 - 19
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merging with the Merge Manager (cont.)
19
Merging with the Merge Manager (cont.)
4Select the view to whichyou are merging, andthen click Next.
Specify the view to which you are merging. The view should be looking at the tip of thebranch you want to merge to.
8/9/2019 05_scm271_ecc_s03
20/28
Essentials of Rational ClearCase
3 - 20 Copyright IBM Corp. 2003
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merging with the Merge Manager (cont.)
20
Merging with the Merge Manager (cont.)
5
Select the specificelements that youwant to merge.
Select elements to be merged, and then click Add or Add All to move them to theElements to be considered list. You can select individual elements or entire VOBs. Toremove the element from the Elements to be considered list, select it, and then clickRemove or Remove All.
8/9/2019 05_scm271_ecc_s03
21/28
Module 3 - Merging to and from the Integration Workspace
Copyright IBM Corp. 2003 3 - 21
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merging with the Merge Manager (cont.)
21
Merging with the Merge Manager (cont.)6
Choose a method forselecting the version ofeach element to merge.
Merge from LATEST elementon a selected branch
Merge from elementsaccording to a specified label
Use a ClearCase query languagestatement to select the from versions
Choose from the following selections:
Select LATEST from a branch tells ClearCase to merge from LATEST element ona selected branch
Select based on label tells ClearCase to merge from elements according to alabel that you specify Advanced version-selector use a ClearCase query language statement to select
the from versions
8/9/2019 05_scm271_ecc_s03
22/28
Essentials of Rational ClearCase
3 - 22 Copyright IBM Corp. 2003
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merging with the Merge Manager (cont.)
22
Merging with the Merge Manager (cont.)7
Provide additionalinformation needed for themerge, then click Finish.
8
Confirm your selectionof merge criteria, thenclick Find.
For this selection Select Yes if you want------------------------------------------------------------------------------------------------------------ Automatically merge all directories that require a directories
merge to be merged automatically;
ensures that the Find Wizard finds allelements that require a merge
------------------------------------------------------------------------------------------------------------ All elements in directory every element, including sub- directories and
files, to be considered for merge; select No toconsider only the directory
------------------------------------------------------------------------------------------------------------Follow VOB symbolic links follow links
Once you have confirmed our selection of merge criteria, click Find to start the merge.
8/9/2019 05_scm271_ecc_s03
23/28
Module 3 - Merging to and from the Integration Workspace
Copyright IBM Corp. 2003 3 - 23
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merging with the Merge Manager (cont.)
23
Merging with the Merge Manager (cont.)
9ClickYes to startthe merge. Ifnecessary, thediff/merge tool willstart.
ClearCase findselements thatneed to bemerged andprompts you tomerge.
8/9/2019 05_scm271_ecc_s03
24/28
Essentials of Rational ClearCase
3 - 24 Copyright IBM Corp. 2003
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merging Directories
24
Merging Directories A directory merge:
Can process two or more versions of the same directoryelement
Results in a new directory version that reflects the contentsof all the contributors
Cannot process two different directory elements
To perform a directory merge:
Make sure the config spec selects the target version
Make sure all contributor versions are checked in
Check out the target version of the directory
Perform the merge immediately without making any otherchanges to the checked-out version
Directory versioning is separate from file versioning. When you merge the contents oftwo directories, you are merging the list of names, not the contents of the files withinthe directories. You must merge file elements separately or use the Merge Manager.
You perform directory merges in the same way that you perform file merges.
8/9/2019 05_scm271_ecc_s03
25/28
Module 3 - Merging to and from the Integration Workspace
Copyright IBM Corp. 2003 3 - 25
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Merging Directories (cont.)
25
Merging Directories (cont.)In the Merge Tool, resolving changes for directories is the same
as with files, but using element names instead of text.
8/9/2019 05_scm271_ecc_s03
26/28
Essentials of Rational ClearCase
3 - 26 Copyright IBM Corp. 2003
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Module Review
26
How does the ClearCase merge algorithm work?
What element types can be merged? What element
types cannot be merged?
What are the three types of merges that the
ClearCase merge tool identifies? How does it handle
each merge type?
When merging versions, how does ClearCaseautomatically resolve conflicts between contributors?
What is the Merge Manager? Why would you use it?
Module Review
8/9/2019 05_scm271_ecc_s03
27/28
Module 3 - Merging to and from the Integration Workspace
Copyright IBM Corp. 2003 3 - 27
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Module Lab
27
In this lab, you will perform the following tasks:
Merge using the Version Tree Browser
Merge using the Merge Manager
Resolve merge conflicts using the Diff Merge tool
Module Lab
8/9/2019 05_scm271_ecc_s03
28/28
Essentials of Rational ClearCase