Removed /usr/local from CDPATH
[clearscm.git] / cc / lscset
1 #!/usr/bin/perl
2 ################################################################################
3 #
4 # File:         lscset,v
5 # Revision:     1.1.1.1
6 # Description:  This script will list change sets for activities
7 # Author:       Andrew@DeFaria.com
8 # Created:      Thu Apr 27 18:10:37 PDT 2006
9 # Modified:     2007/05/17 07:45:48
10 # Language:     Perl
11 #
12 # (c) Copyright 2006, Andrew@DeFaria.com, all rights reserved.
13 #
14 ################################################################################
15 use strict;
16 use warnings;
17
18 use FindBin;
19 use lib "$FindBin::Bin/../lib";
20
21 use OSDep;
22 use Display;
23 use Clearcase;
24 use Utils;
25
26 my $me = $FindBin::Script;
27
28 # This is site specific - and problematic!
29 my $pvob_name = "ilm_pvob";
30 my $pvob = ($arch eq "windows" or $arch eq "cygwin")    ?
31   "\\" . "$Clearcase::vobtag_prefix$pvob_name"          :
32   "$Clearcase::vobtag_prefix$pvob_name";
33
34 sub Usage {
35   my $msg = shift;
36
37   display "Usage: $me: <activity> [ <activity> ]";
38
39   if (defined $msg) {
40     error "$msg", 1;
41   } # if
42
43   exit 0;
44 } # Usage
45
46 sub GetChangeSet {
47   my $activity          = shift;
48   my $current_view      = shift;
49
50   my @changes;
51   my $cmd       = "cleartool lsactivity -l $activity\@$pvob 2>&1";
52   my @output    = `$cmd`;
53   my $status    = $?;
54
55   if ($status ne 0) {
56     warning "$activity Activity does not exist";
57     return;
58   } else {
59     my $found_changeset = $false;
60
61     foreach (@output) {
62       if (!$found_changeset) {
63         if (/  change set versions/) {
64           $found_changeset = $true;
65           next;
66         } else {
67           next;
68         } # if
69       } else {
70         if (/\s*(.*)/) {
71           my $element = $1;
72           # Trim off view stuff
73           if ($element =~ /$current_view(.*)/) {
74             $element = $1;
75           } # if
76           push @changes, $element;
77         } # if
78       } # if
79     } # foreach
80
81     return @changes;
82   } # if
83 } # GetChangeSet
84
85 sub GetPWV {
86   my $cmd       = "cleartool pwv -s";
87   my @output    = `$cmd`;
88   chomp @output;
89   my $status    = $?;
90
91   my $view = $output [0];
92   chop $view if $view =~ /\r/;
93
94   if ($status ne 0 or $view =~ /\*\* NONE \*\*/) {
95     return undef;
96   } else {
97     return $view;
98   } # if
99 } # GetPWV
100
101 sub DisplayChangeSet {
102   my $activity  = shift;
103   my @changes   = @_;
104
105   display "$_" foreach (@changes);
106 } # DisplayChangeSet
107
108 Usage "Must specify an activity" if !defined $ARGV [0];
109
110 # Should probably make a constructor for Clearcase::View to return the
111 # current view, if any.
112 my $current_view = GetPWV;
113
114 Usage "Must be in a view" if !$current_view;
115
116 my @activity = @ARGV;
117
118 DisplayChangeSet $_, GetChangeSet $_, $current_view foreach (@activity);