How to list branches associated with a view in clearcase - clearcase

I have checked in some files in a branch but unfortunately I forgot the branch name but I remember my view name to which my branch is associated. I also checked my config spec but the branch which is written in the config spec is not the branch that I want.
Actually I created two branches in a view but one branch name I forgot and as I said in config spec also only one branch name is written. Is there any way where I can list all branches associated with a particular view?

No: only an UCM view has an associated branch (through its stream).
See "How to obtain UCM stream and baseline with cleartool?" or "How to get ClearCase stream name by a given view path?"
cleartool lsstream -fmt "%n" -cview
A non-UCM view would have any selection rules you want in its config spec.
You need to do a cleartool lsvtree /path/to/a/file (add --graph for the graphical view) in order to see its versions and the branches involved.

Related

How to do code merge from one branch to another in 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.

Clearcase: Activity branch information

Is there any command which will display all the information associated with a particular activity branch. Like:
On which label it was created?
On which label currently it is?
What are the files are checked in the branch. What are there latest versions?
Who created this branch?
Is there any single command for all those which will display these information (not in graphical view)
The only two commands are:
cleartool lsact
cleartool descr -l activity:anActivity#/apvob
You can get that way the list of versions for each file.
See also "Cleartool command to list all files part of a changeset"
You can combine the second command (descr) with a -fmt (fmt_ccase) directive in order to get other activity attributes, like its associated view (from which you can deduce the stream)
But that won't give you from which label the activity started. For that, you can list the foundation baseline of the stream.
And that won't give you "On which label currently it is?": the activity list versions. The fact that those versions are or are not labelled is not relevant for the activity. You would need to describe the version in order to see if it has a label attached to it.
If this is UCM, and by "activity branch" you mean the stream it is on, you can get the information about the stream by using cleartool lsstream -long -cview while in the view in question. The output will look something like this:
stream "brian_testrep1_2"
2017-08-17T17:50:15-04:00 by Brian.None#DESKTOP-LQ0QA86
owner: DESKTOP-LQ0QA86\Brian
group: DESKTOP-LQ0QA86\None
project: testrep1#\testproject (development stream)
default deliver stream: testrep1_Int#\testproject
development streams:
contains activities:
foundation baselines:
test_2#\testproject (testcomp1#\testproject) (modifiable)
recommended baselines:
views:
Brian_testrep1_2
policies:
...

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.

How to add a fine in existing clearcase baseline? (Not the latest baseline)

Is it possible to add a file in existing ClearCase baseline (Not the latest baseline) ?
Scenario :
There is a component , say CC_COMP having a number of baselines created over time. Consider below baselines in the component CC_COMP
BL_Latest
BL_New
BL_Older
BL_Oldest
There is a file FILE already present in BL_Lastest which is ONLY version in the VOB.
Now I want to add the same file FILE ( logically different but same in name ) in the baseline BL_Older.
How can I add that file in that older baseline?
No: a baseline is, by its very definition, immutable.
See for instance the article "The power of Unified Change Management"
These baselines are semantically rich objects that identify a "version" of a UCM component.
By using them, you can be certain that all files in that component are associated with the same version.
You can also be certain that the baseline will not change out from under you.
Once created, UCM baselines are immutable and can be used for defining higher-level configurations. An entire system, for example, can be assembled from a set of component baselines.
You need to:
create a substream to the stream where BL_Older was created
rebase or initialize that substream with the BL_Older baseline
add your file (using an UCM view associated with that stream)
make a new baseline BL_Older.1 for example.

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.

Resources