How to do code merge from one branch to another in ClearCase - clearcase

I an new to ClearCase and started studying the ClearCase documentation.
UseCase : I have two branches - 'Branch_A' and 'Branch_B'.
I need to merge all my changes from 'Branch_A' to 'Branch_B'
I won't be able to use the ClearTeamExplorer, so only option is command line.
I read the documentation and its mentioned that cleartool findmerge command is the option for it.
But there is no direct example given for this.
Could someone please provide an command line example for this please?
Any help on this is appreciated.

Assuming a base ClearCase view/branch (no UCM views/Streams):
cleartool findmerge include a relevant example:
for the current directory subtree, compare versions visible in the current view against versions on another branch and perform any required merges.
cd /path/to/target/Branch_B/view
cleartool findmerge . –fversion /main/Branch_A/LATEST –merge –gmerge.
The idea is to be in the view set on the target branch, with a config spec ready to create new versions.
element * CHECKEDOUT
element * .../Branch_B/LATEST
element * /main/0 -mkbranch Branch_B
element * /main/LATEST -mkbranch Branch_B
The merge is done in the target view, on the target branch.
Now if you are using UCM, then the view done on a Stream has already the right config spec.
The idea remains the same: Execute the findmerge in the target view (after setting a dedicated activity, to record that merge)
In that case, check "How to merge changes from a specific UCM activity from one ClearCase stream to another"
You do not merge branches in UCM, you would merge UCM activities.

Related

ClearCase checkout branch in VOB

I'm new to CC and I'm coming from Git and Mercurial background, probably thats why ClearCase confused me so much. I've been assigned a task to migrate latest CC's revisions to Git. Problem is that I couldn't manage to checkout any branch other than main in CC.
I have a view that displays all VOB's /main/LATEST revision. I assume, main branch's latest revision.
element * CHECKEDOUT
element * /main/LATEST
Now I need to get the list of other branches in a particular VOB. To do that, I navigate from terminal in that folder and run
cleartool lstype -kind brtype -invob /%VOB_NAME%
and I can see the list of branches. Correct me if I'm wrong, but I assume, it displays only the branches relevant to VOB(%VOB_NAME%).
Now I need to checkout the branches. What is the standard way of doing this. I tried updating config spec with something like:
element * /%VOB_NAME%/%BRANCH_NAME%/LATEST but it doesn't seem to work.
Pretty sure I'm not doing it correctly.
Also for migration purpose, I'll need to automate the steps to acquire branches and checkout the branches. I guess updating config spec to switch branch in a view takes some time and probably is an async operation, so is there a way to determine when view finishes updating?
Or maybe there's command line option to switch branch for a particular VOB in a view?
So in short, here's my questions I'm struggling with:
Than
Am I acquiring VOB branches correctly?
How can I checkout a particular branch?
Is there a way to determine when checkout finishes?
thanks
UPDATE
ok I tried #VonC's recommendation so my config spec looks like this:
element * CHECKEDOUT
element * .../heine_1/LATEST
element * /main/LATEST
If I'm guessing correctly, one VOB containing branch named heine_1 should checkout that particular branch, the rest of VOBs will stay on main branch, but this is not the case. When I run cleartool ls inside that VOB, its still on main branch. All folders are postfixed with Rule: /main/LATEST. So I guess it didn't switch the branch.
Thanks
There are a few questions in the original question and the comments.
Addressing the configspec issue first...
The syntax of an element rule is:
element {path} {version rule} {optional clauses}
If you need a VOB-specific rule, you can do something like this:
element \myvob\... ...\myvobbranch\LATEST
element \myvob\... \main\LATEST -mkbranch myvobbranch
The "..." in the path means "this location and everything underneath it."
The "..." in the "version rule" means that the branch name is at the end, so this would match /main/myvobbranch/LATEST, /main/br1/myvobbranch/LATEST, etc.
If you're working on a branch, you generally want new files or work to appear on the branch you are working in, and the second line makes that happen.
Everything in a configspec is case sensitive, so be aware that "LATEST" is not "latest."
Since the view was created for you, I'm reasonably certain that it is a dynamic view. If it is mapped to a drive, it's definitely dynamic. If you need to know for sure, you can CD into the "working area" of your view and run "cleartool lsview -pro -full -cview" and look at the "attributes" line. The line for a dynamic view will look like this:
Properties: dynamic readwrite shareable_dos
On the direct questions:
Yes, you are acquiring the branch list correctly.
By default the checkout is done using the version selected by the view, you can use cleartool checkout -branch {full branch path} {file name} to check out the latest on a branch, or cleartool checkout -version {version id} {file name} to check out a version other than the latest on a branch. I would not recommend either as a normal practice. The -branch will cause checkins to go to the element's parent branch. The -version would require add a requirement to perform a merge to get the checkin to complete, which would also go to the version's parent branch.
Checkout is finished when the command finishes.
A big "new user gotcha" is that directories are also versioned objects. If you're adding files to source control, you need to remember to check the directory in so that they are visible by others with similarly configured views. The ClearCase GUIs have this behavior as a default if you started the process with the directory NOT checked out, but not if you explicitly checked out the directory beforehand.

Clearcase UCM - How to get the config spec of a given baseline?

I'd like to set-up a non-UCM clearcase (read only) view for debugging an issue reported on a old baseline which was delivered to customer.
How to view/retrieve/generate the config spec of the old baseline? so that I use this config spec to create a non-UCM clearcase view for debugging the issue.
The config spec is simple:
element * baseline_id
element * /main/0
element * /main/LATEST
(note that the /main/0 is important, especially in a multi-component vob, for the initial version of the component is registered in /main/0 when a new component is created)
What you need to find out is:
what is the baseline id? (which can differ from the baseline title).
See "Display Current Baseline with Cleartool".
You can for instance describe the stream to get the foundation baselines id:
cleartool descr -fmt "%[found_bls]CXp" stream:myStream#\myPVob
is the baseline a full or an incremental one? See "What is the difference between Full baseline and Incremental baseline in Clearcase UCM?".
If it is an incremental one, you need first to promote the baseline to a full one.
ct chbl -full -nc baseline:abaselinexxx.yyyy#\apvob
I think a much simple solution is to create a stream based on the baseline you have. That way you can even write into it without interfering nothing and even to save you changes in CC
It's very simple to create a stream based on a baseline, click the "advanced" option when creating stream as usual.
Enjoy,
Eli.

Is it possible to check the history of the files in a clearcase view?

I had some files in my view few days back and I need to recreate those files. Now I want to see which file changed from that period of time. Is it possible in clearcase to see the history of the view and to check what are the files that were changed from that period of time?
One solution is to make a snapshot view with time-based selection rules, with a config spec similar to:
element /myPath/... .../StreamName/{!created_since(16-Sep-2009)}
element /myPath/... /main/{!created_since(16-Sep-2009)}
element /myPath/... /main/LATEST
To quickly list all modified files since a certain daye, use a cleartool find command:
cleartool find <vobtag> -element "{created_since(target-data-time)}" -print
Not only can you compare it with your current view, and find what has changed, but you also can copy over the older files in your current view.
See also:
ClearCase : how to revert / get a snapshot view of a specific date/baseline?
Get all versions from a specific time - ClearCase UCM
Find files in Clearcase view newer than a specific date?

branching from multiple files in clearcase

I have around 5000 files for which i have to create a branch(say my_branch) from main branch,checkout those files,check in and then apply label.
Its practically impossible to seperately create branch for each file and do the other steps.
There is a way to apply common label to all checkout files and check in all checked out files..that reduces my work but is there a way to create branch for 5000 files with just one cmd or are there any tool to do so
Thanks in advance
Yes, if you have a snapshot view ready to create that branch for you, meaning with a config spec like:
element * .../myBranch/LATEST
element * /main/LATEST -mkbranch myBranch
element /main/0 -mkbranch myBranch
(assuming here that your files are for now on /main)
In that case, what you do is:
copy and update your 5000 files somewhere else
clearfsimport them into your snapshot view: 5000 files will be checked out, updated, checked-in in the right branch for you, one by one, automatically.
See "How to run clearfsimport command for similar streams" as an example for the clearfsimport command.

Details of config spec in base ClearCase

My base ClearCase config spec reads like this:
element * CHECKEDOUT
element * .../Branch_F13R2/LATEST
All is good, but I am wondering what is the .../ doing at the beginning of the path? In UCM, we can see the streams and VOBS in Clear Case explorer, but in base ClearCase, how to know that if I want to check out from Branch_F13R2, I need .../ at the beginning?
That is because you don't know the parent branch.
.../ in a selection rule allows for ClearCase to select that branch, from whatever branch it comes from: /main, or any other branch.
To see more about that notation, called ellipsis wildcard, see "Find all files modified in a specific ClearCase branch?".
I would also recommend to add the rule
element * /main/LATEST
Not every parent directory has a version in the branch you are looking for, and without this last selection rule, it would have nothing to select, making any sub element inaccessible.

Resources