2

How to find root folder in which a component is associated?

I am able to find it manually through project explorer -> Components-> properties

How to do it using cleartool command. I need it as i need to create config spec which can be applied in base clearcase view and view the UCM view contents.

Samselvaprabu
  • 16,830
  • 32
  • 144
  • 230

1 Answers1

2

Have a look to the options of "Format strings for command output" (fmt_ccase):

 cleartool descr -fmt "%[root_dir]p" component:aComponent@\aPVob

You can get that way to root directory (usually \aVob for "vob component" or "\aVob\aRootDir" for components within a Vob).


From there, for managing access to specific baselines of UCM components in non-UCM views, you can follow an approach similar to "Merging from a Project to a Non-UCM Branch" in a perl script (done to merge, but you can adapt it, in order to build a config spec for said non-UCM view):

This script below is for projects which uses recommended baselines, and is given as an example of using the "%[root_dir]p".
If you don't use recommended baselines, you would simply list all components for a given stream:
cleartool descr -fmt "%[components]CXp" stream:aStream@\aPVob

print("######## Getting recommended baselines for project 
'$project'\n");
my @recbls = split(' ', ‘cleartool lsproject -fmt "%[rec_bls]p" 
$project‘);

foreach $bl (@recbls) {

    my $comp = ‘cleartool lsbl -fmt "%[component]p" $bl‘;
    my $vob = ‘cleartool lscomp -fmt "%[root_dir]p" $comp‘;

    #... build your config spec there
}
# call cleartool setsc there

You would then generate (and apply to a config spec) a file similar to your other question "Clearcase config spec behaves odd when using setcs command".


The OP reports getting this approach working, using Powershell:
(he had initally issues with my example copied form the IBM site, where hyphens-minus '-' are replaced by non-ASCII minus '': , '- vs. –: -–': see "What's the toughest bug you ever found and fixed?"):

$project="MyComponents@\My_PVOB" 
$pvob="@\My_PVOB" 
$Baselines=(cleartool lsproject -fmt "%[rec_bls]p" $project).split() 
foreach ($bl in $Baselines) { 
  $comp=cleartool lsbl -fmt "%[component]p" $bl"$pvob" 
  $vob = cleartool lscomp -fmt "%[root_dir]p" $comp"$pvob" 
}
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • use strict; my $project="Components@\My_PVOB"; my $bl; print("######## Getting recommended baselines for project '$project'\n"); my @recbls = split(' ', `cleartool lsproject -fmt "%[rec_bls]p" $project`); foreach $bl (@recbls) { my $comp = `cleartool lsbl –fmt "%[component]p" $bl`; my $vob = `cleartool lscomp –fmt "%[root_dir]p" $comp`; #... build your config spec there } # call cleartool setsc there exit 0; " It fails as "cleartool: Error: Unable to determine VOB for pathname "My_PVOB"." I tried for 2 hours to solve but failed . What am i missing? – Samselvaprabu Jan 07 '12 at 16:58
  • @Samselvaprabu First you need to know at what line it fails (`lsbl`? `lscomp`?). Then make sure (it never hurt to ask) that you have the right name/path for your PVob: `\MyPVob` for Windows, `/vobs/MyPVob` for Unix (and replace '`MyPVob`' by the name of your actual PVob of course). Finally, simplify. Make your script a one liner, trying to `lsbl` or `lscomp` just one object, and see if this works. Once you have debugged that, the rest of the initial and more complete script should work. – VonC Jan 07 '12 at 20:12
  • @Samselvaprabu: if you still have issues with some `cleartool` commands within that script, put the complete `cleartool` command and its complete output in those comments: I will debug them. – VonC Jan 07 '12 at 20:13
  • Thanks buddy .I think your contents are copied from some pdf or some other format. That is giving some utf format issues. Moreover PVOB name in windows requires @\PVob. "$project="MyComponents@\My_PVOB" $pvob="@\My_PVOB" $Baselines=(cleartool lsproject -fmt "%[rec_bls]p" $project).split() foreach ($bl in $Baselines) { $comp=cleartool lsbl -fmt "%[component]p" $bl"$pvob" $vob = cleartool lscomp -fmt "%[root_dir]p" $comp"$pvob" }" (I have used powershell ) – Samselvaprabu Jan 08 '12 at 07:35
  • Yes. Thanks buddy for going extra mile in your answer. ( Can you edit your answer? So that people who read your answer may not face format issue which i faced – Samselvaprabu Jan 08 '12 at 10:12
  • @Samselvaprabu: Excellent. I have edited my answer to include your conclusions, and I have fixed all the minus signs, replacing it by hyphen-minus. See http://stackoverflow.com/questions/169713/whats-the-toughest-bug-you-ever-found-and-fixed/170148#170148 – VonC Jan 08 '12 at 13:22