ClearCase UCM: Access and change config spec from script - clearcase

In our continuous integration we use ClearCase UCM. We occasionally need to access the sources from the recommended baseline (which not necessarily equals the newest baseline). Note: All baselines are full.
I figured out how to access the sources belonging to the recommend baseline manually, by entering cleartool edcs in the command line within the dynamic view and adding the line element * MyRecommendedBaseline below # Select checked out versions, saving and closing the text-file.
Unfortunately I don't know how to do this from a script. One way I could think about is read the contents of the config_spec into a stream, add the line, save it to a new text file and use "cleartool setcs newcs.txt".
But apart from being cumbersome I'm not exactly sure if this is possible. Anyone knows a simple way to do this?

You can script listing the recommended baselines of a given stream: see "How can I list the recommended base line in ClearCase"
On Windows:
cleartool descr -fmt "%[rec_bls]CXp" stream:streamName#\aPVob
On Unix:
cleartool descr -fmt "%[rec_bls]CXp" stream:streamName#/vobs/aPVob
From there, you can generate a new file with simple rules:
element * MyRecommendedBaseline1
element * MyRecommendedBaseline2
...
And you can setcs that file to a dedicate base-CC dynamic view (not an existing UCM view).
As Brian Cowan points out in the comments, this only works because those baselines, as the OP mentions, are full baselines (not incremental or not-labeled, like deliverbl are).
See also "What is the difference between Full baseline and Incremental baseline in Clearcase UCM?".

Related

How to get list of activities included in new ClearCase baseline from commandline?

When making baseline manually, it shows the "Make Baseline" dialog with list of activities to include in new baseline.
How to get that list from commandline (from cleartool or other tool, in Windows and Linux)?
The closest would be described in the technote "Activities delivered since the last baseline"
When working in a UCM project, it is often useful to determine the activities delivered to an integration stream since the last baseline was applied.
The cleartool diffbl command can accomplish this.
However, cleartool diffbl must be run against each modifiable component that the project uses.
The command syntax is:
cleartool diffbl -activities baseline:<baseline> stream:<integration_stream>
That means you must determine that latest most recent baseline of a component on a given stream first.
As mentioned by the OP in the comments, the diffbl works with the most recent baseline:
either the one listed first by lsbl
or the foundation baseline if it is more recent.
cleartool lsbl -stream integration_stream -component user1_comp#/vobstore/pvob
Then make the diffbl in order to list the activities which are candidate for the next baseline.
The cleartool lsbl -stream ... -component ... seems to return the last baseline created in this stream.
But cleartool diffbl -activities baseline:... stream:... prints some useless junk if that baseline is not last in stream (this might happen if stream was rebased, and no new baseline was created since then; the last baseline becomes the foundation baseline).
So cleartool diffbl needs foundation baseline if it's newer than last baseline created in the stream. In this case it correctly outputs list of activities.

How to find the list of files changed after latest baseline in UCM?

I have to verify whether any elements are changed in a component vob after the last baseline in applied.
I was trying to find the cleartool command for that but i got upto "finding the list of files changed after a particular date " .
Is there any way to get the list of files changed after the last baseline applied?
One of the fastest way would be simply to try and make a baseline(!)
If nothing has changed, by default, ClearCase UCM will refuse to make one.
If one has change:
a/ You can compare the newly created baseline with its previous to get the list of versions modified:
cleartool diffbl -pred -ver newBaseline#\aPVob
b/ You can delete that newly created baseline if your intention was not to create one right away.
Another relatively fast way (since adding/removing a baseline can take time on a large component, or where there are already a lot of baselines) is:
"Find files in Clearcase view newer than a specific date?"
If you have the date of the last baseline, you can launch a search for newer version:
cleartool find <vobtag>/<component_root_dir> -element "{created_since(target-data-time)}" -print
To get the latest baseline, see "List the latest baseline of a component in a UCM stream one by one".
The date can then be obtain with an fmt_ccase directive:
cleartool describe -fmt "%d" aBaselineName#/aPVob
The best,simplest and easiest way to do that is by creating a view in that baseline and then give a cleartool rebase -recommended .Once you do this just give cleartool lspriv -co This will give you list of all the files that have been modified after your baseline in which you created the view.

How to rename member baseline? Is it acceptable practice?

I have applied baseline for a component via cleartool. (we are using clearcase UCM).
I mistakenly put the wrong baseline name and i am unable to apply another one as it says no changes were done.
How to rename the baseline name in UCM ? (I tried via GUI but not finding a way).
If cleartool rmname can be used, can some one put an example how to do that? i did not find one
As mentioned in "Renaming a Baseline does not change the label type name", you can rename a baseline through the CLI) but you need to rename the assiciated lbtype as well, for ClearCase 7.0 and before (7.1 and 8, you can just rename the baseline, it should take care of the lbtype. If not, see below).
cleartool rename baseline:<old baseline name>#\<component vob tag> baseline:<new baseline name>#\<component vob tag>
Check if the lbtype is renamed by doing a:
cleartool descr -l baseline:<new baseline name>#\<component vob tag>.
ClearCase does not rename the lbtype automatically when a baseline is renamed because the lbtype is used as a version selector in every view that is attached to a stream using this baseline (as illustrated in [IBM technote swg1IC41518][2]).
If a UCM baseline lbtype is also renamed, it is necessary to run 'cleartool chstream -gen stream:<stream#pvob>' for every stream using this baseline.
It is then necessary to run 'cleartool setcs -stream' within every view associated to the stream.
Since it cannot be guaranteed that every view is available to the system that is renaming a UCM lbtype, this cannot be automated.
cleartool rename lbtype:<old baseline name>#\<component vob tag> lbtype:<new baseline name>#\<component vob tag>
In short, it is possible but not trivial to rename a baseline for CC7.0 and before: it is an UCM object which is assosiated (through an hyperlink) to the lbtype used to create the label on all the elements which have changed (incremental baseline), or all the elements of the component (even those which haven't changed since the last baseline: full baseline, see "What is the difference between Full baseline and Incremental baseline in Clearcase UCM?")
You need to rename both (baseline and lbtype).
It is an acceptable practice since its content doesn't change.
However, you would need to propagate and communicate the new baseline name along your release management process.

How to find a particular file version in ClearCase?

Is there any command in which I provide a baseline name plus an element filename, and it returns the exact file version that is labeled by this baseline?
For instance:
baseline name: 7.5.3.1
element filename: a.java
Result:
/main/mystream/16
My question refers to UCM, where you can't move a baseline between versions...
If there's no such command, it seems I have to write a short script. In that case, I probably have to run cleartool lsvtree and then parsing the output - am I right? Is that the most rapid way?
Thank you
You could query the exact version by looking at the label on the version of that file.
But that would only work if the baseline is a full baseline (meaning it has set a label named after the baseline on each file part of the component associated with said baseline).
See "What is the difference between Full baseline and Incremental baseline in Clearcase UCM?".
If that is the case, then you can look to the exact version with a cleartool find command, like in "How to search files by label".
Other mechanisms are described in the IBM technote "How to determine which element version a label was moved from".

Accessing an eclipsed element in ClearCase

In my current working environment, I make use of eclipsed files extensively for testing purposes. When it comes time to formalize things, I have a script which generates a diff by comparing the file with a backup saved by my eclipse script.
I'd like to be able to work without the backup of the original file; is there any way I can retrieve the current version of the file that I can pass to diff? Even though the file is view-private, I see I can enter foo##/ and see a list of versions, but I'm not sure how to find which version is the latest. Everything I've tried using cleartool ls or describe with the file name tells me that it's not a VOB object (which is true, although cleartool ls does show it as eclipsed, so it must know, somehow, that there is an element there)
Thanks
Eclipsed file means dynamic view.
The simplest solution would to make a second dynamic view based on the same config spec.
Considering how cheap and quick those views are, this isn't an issue.
On that second dynamic view, you can do a
cleartool descr -fmt "%Xn" /path/to/element
In order to get the extended pathname of the file (see fmt_ccase for more on the %Xn syntax).

Resources