How to find a particular file version in ClearCase? - 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".

Related

ClearCase UCM: Access and change config spec from script

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?".

How to find activities of a modified files in Clearcase

I have a file test.cpp somebody added a few lines of code i don't know when but i'm assuming it was in a specific range of time that i know.I want to find the activity that was used to deliever this changes, i found a lot of versions of this element in the version tree of this element, but all the activities that i was able to see were as a result of a rebase, i need to find the source activity that was in charge of adding this few lines of code.
Is there any way to do that ?
For each deliver activity (that you can see in the version tree), you can list the contributing activities with
cleartool lsact -contrib activity:anact#/apvob # on unix #/vobs/apvob
See "Finding which developer activities were delivered in a specific delivery"
Then you need to describe each activity found, to see if your file is in it.
cleartool descr -l activity:anact#/avob
Obviously, you also can use a cleartool annotate, in order to see the versions in that file: see "How to use ClearCase Annotate".
If you see one line which interest you, check its version n# 'x' and use cleartool descr -l file#/main/.../x to find its corresponding activity.

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.

clearcase latest version of a file on a particular branch

I know the filename of a clearcase versioned file. How can i find the latest version of this file on a particular branch ? It should not pick any child branches. Also the parent branch names may not be know always.
Thanks.
If you are using a dynamic view, you can directly access the LATEST version of a given branch by using the extended path:
cat file##/main/branch/subbranch/LATEST
If you don't know the exact branch path (parent branches) this version is stored in, you can modify your dynamic view and add first the selection rule
element /path/to/file .../subbranch/LATEST
That will select the LATEST version of subbranch within the dynamic view.
Or you can do a cleartool find, in order to see the full extended path for that file:
cleartool find . -name "yourFile" -ver "version(.../subbranch/LATEST)
You will be able to cat (or type in Windows) directly the result (which will be the full extended path)
The diea behind the cat or the cleartool find is to be able to use the syntax .../subbranch/LATEST.
That syntax with the three dots means: '.../subbranch' whatever branches followed by /subbranch.

Resources