How can I interact with ClearCase from Perl?

送分小仙女□ 提交于 2019-12-28 02:18:48

问题


My project needs couple of things to be extracted from ClearCase data using the Perl script in a excel sheet,those are -
By giving two particular time line or two baseline.

  1. all the activity associated within that baseline (column header "activity")
  2. Owner's id (column header-Owner)
  3. all the element associated within a particular activity. (column header-"element details")
  4. For each element the versions associated (column header-"Versions")
  5. for each element the total number of lines of code,total number of lines of code added,total number of lines of code deleted,total number of lines of code changed..(column header"No. of lines of code","lines of code added","lines of code deleted" & " lines of code changed")

Please kindly help me on this...


回答1:


Basically, ClearCase Perl scripting is based on parsed outputs of system and cleartool commands.

The scripts are based on a cleartool run cmd like package CCCmd, and used like:

use strict;
use Config;
require "path/to/CCCmd.pm";

sub Main
{
  my $hostname = CCCmd::RunCmd('hostname');
  chomp $hostname;
  my $lsview = CCCmd::ClearToolNoError("lsview -l -pro -host $hostname");
  return 1;
}

Main() || exit(1);
exit(0);

for instance.

So once you have the basic Perl structure, all you need is the right cleartool commands to analyze, based on fmt_ccase directives.

1/ all the activity associated within that baseline (column header "activity")

 ct descr -fmt "%[activities]CXp" baseline:aBaseline.xyz@\ideapvob

That will give you the list of activities (separated by ',').

For each activity:

2/ Owner's id (column header-Owner)

 ct descr -fmt "%u" activity:anActivityName@\ideapvob

3/ all the element associated within a particular activity. (column header-"element details")

Not sure: activities can list their versions (see /4), not easily their elements

4/ For each element the versions associated (column header-"Versions")

For a given activity:

 ct descr -fmt "%[versions]CQp\n"  activity:anActivityName@\ideapvob

5/ for each element the total number of lines of code,total number of lines of code added,total number of lines of code deleted,total number of lines of code changed..(column header"No. of lines of code","lines of code added","lines of code deleted" & " lines of code changed")

That can be fairly long, but for each version, you can compute the extended path of the previous version and make a diff.

I would advise using for all that a dynamic view, since you can access any version of a file from there (as opposed to a snapshot view).




回答2:


Also if you need to use perl with Clearcase have a look at the CPAN module ClearCase::CtCmd. I would recommend to use this perl module for invoking clearcase commands.




回答3:


For the CCCmd package, I had to remove the double-quotes in the RunCmd and RunCmdNoError subs to get it to work.



来源:https://stackoverflow.com/questions/2273200/how-can-i-interact-with-clearcase-from-perl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!