2

We are developing a tool using c# for purpose of code reviews. We are using clearcase as source control.

I am using "cleartool" object to perform any operations interacting with clear case {ex of ClearCase operations: getting list of labels present, files attached with given label etc...}

The requirement before using cleartool is that i have to change my working directory to appropriate VOB directory.

Say for example I have "exampleView" and "exampleVOB" on network drive "U". So in my code

  • step 1. Change my working directory to VOB directory "cd U:\exampleView\exampleVOB"
  • step 2. interact with clear case using cleartool commands.

Problem :

So now from my tool design is

  1. I have 2 combobox one for views and other for VOBs.
  2. User selects appropriate View and VOB.
  3. Through code get clear case network drive using registry entry "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Mvfs\Parameters\basedrive"
  4. I form path as "basedrive:\viewcomboboxselection\vobcomboboxselectedvalue"

So now i wanted to know is there any way to get list of VIEWS and VOBS in a given system.

My findings so far :

  1. Registry entry "HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Atria\ClearCase\CurrentVersion\RecentlyUsedViews" will give me only selected views but not all views in a system.
  2. Registry entry "HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Atria\ClearCase\CurrentVersion\PersistentVOBs" will not give me all VOBs in a given system.

Is there any registry entries or any way to get list of all views and vobs in a system.

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Sandeep
  • 341
  • 1
  • 9

3 Answers3

0

1.To get all the vobs from clearcase

ccApp = new ClearCase.Application();
ClearCase.CCVOBs ccVobs =  ccApp.get_ProjectVOBs(false, "windows");
foreach (ClearCase.CCVob vob in ccVobs)
{
   //Process it
}

2.To get all the views for a particular stream

ClearCase.CCProjectVOB ccVob = ccApp.get_ProjectVOB(projectVob);
ClearCase.CCViews ccViews = ccVob.get_Stream(selectedStream).Views;
foreach (ClearCase.CCView ccView in ccViews)
{
  //Process it      
}
Ramesh K
  • 41
  • 4
0

To get all the view for a given hostname, see cleartool lsview:

cleartool lsview -s -host anHostname -quick

(Note the -quick for CC7.0.1+ only, which provides faster lookup for the -host option by listing views as currently stored in the registry)


To get all the vobs (in the current region), see cleartool lsvob:

 cleartool lsvob

You can call and (parse the result of) from your C# program, or call a VB script from the same C# program, using CAL API as illustrated in this question.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

As VonC suggests, try using the CAL API.

You will save yourself an enormous amount of trouble by not attempting to invoke and parse cleartool output in C#. If you check out the "cc_cal.chm" in your ClearCase folder (in 'bin' I believe), you'll see the CAL API has a reasonably well-documented class heirarchy, though the examples are largely aimed at VB users (and thus require some adaptation and type casting). You'll see a sizable speed improvement as well, as there's a nontrivial cost to launching new subprocesses in Windows.

Visual Studio's debugger will be your best friend moving forward - add the ClearCase.Application (and possibly ClearCase.Cleartool) references to your project, instantiate an instance of the ClearCase.Application object, then have fun inspecting with the watch window.

Some instructions on enumerating views with ClearCase.Application are available here: http://www.codeproject.com/Articles/41720/Using-the-ClearCase-Automation-Library-with-C

Tom B
  • 519
  • 3
  • 9