How can I interact with ClearCase from Perl?

前端 未结 3 1092
挽巷
挽巷 2020-11-30 15:37

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 baseli

相关标签:
3条回答
  • 2020-11-30 16:01

    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).

    0 讨论(0)
  • 2020-11-30 16:09

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

    0 讨论(0)
  • 2020-11-30 16:13

    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.

    0 讨论(0)
提交回复
热议问题