Subversion Repositories DevTools

Rev

Rev 1329 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
367 dpurdie 1
########################################################################
2
# Copyright (C) 1998-2011 Vix Technology, All rights reserved
3
#
4
# Module name   : jats_ccdelete_view.pl
5
# Module type   : Makefile system
6
# Compiler(s)   : Perl
7
# Environment(s): jats
8
#
9
# Description   : Delete a Clear Case view
10
#                 Need the view tag
11
#
12
# Usage         : See POD at the end of the file
13
#
14
#......................................................................#
15
 
16
require 5.008_002;
17
use strict;
18
use warnings;
19
 
20
use Cwd;
21
use JatsError;
22
use Time::Local;
23
use Pod::Usage;                             # required for help support
24
use Getopt::Long;
25
 
26
my $VERSION = "1.0.0";                      # Update this
27
my $opt_verbose = $ENV{'GBE_VERBOSE'};      # Allow global verbose
28
my $opt_help = 0;
29
my $opt_test;
30
 
31
my @vlist;
32
 
33
#-------------------------------------------------------------------------------
34
# Function        : Mainline Entry Point
35
#
36
# Description     :
37
#
38
# Inputs          :
39
#
40
my $result = GetOptions (
41
            "help|h:+"          => \$opt_help,
42
            "manual:3"          => \$opt_help,
43
            "verbose|v:+"       => \$opt_verbose,
44
            "test"              => \$opt_test,
45
 
46
            );
47
 
48
            #
49
            #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
50
            #
51
 
52
#
53
#   Process help and manual options
54
#
55
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);
56
pod2usage(-verbose => 1) if ($opt_help == 2 );
57
pod2usage(-verbose => 2) if ($opt_help > 2 );
58
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ( $#ARGV < 0 );
59
 
60
#
61
#   Configure the error reporting process now that we have the user options
62
#
63
ErrorConfig( 'name'    =>'CC_DELETE',
64
             'verbose' => $opt_verbose,
65
            );
66
 
67
 
68
#
69
#   Process views and determine information
70
#
71
foreach my $view ( @ARGV )
72
{
73
    my $uuid;
74
    #
75
    #   If the view tag still exists then delete the view the hard way
76
    #   Use 'lsview' to locate the views uuid
77
    #
78
    Verbose("Look for View Tag");
79
    my $cmd = "cleartool lsview -long $view";
80
    open(CMD, "$cmd 2>&1 |") || Error( "can't run command: $!");
81
    while (<CMD>)
82
    {
83
        #
84
        #   Filter output from the user
85
        #
86
        chomp;
87
        Verbose("lsview: $_");
88
        $uuid = $1 if ( m~^View uuid:\s+(.*)~ );
89
        $uuid = $1 if ( m~^\s*View tag uuid:\s*(.*)~ );
90
    }
91
    close(CMD);
92
 
93
    if ( $uuid )
94
    {
95
        Verbose ("UUID: $uuid");
96
        unless ( $opt_test )
97
        {
98
            ClearTool( "--Quiet", "rmview -force -all -uuid $uuid" );
99
            ClearTool( "--Quiet", "unregister -view -uuid $uuid" );
100
            ClearTool( "--Quiet", "rmtag -view -all $view" );
101
        }
102
    }
103
}
104
 
105
#-------------------------------------------------------------------------------
106
# Function        : ClearTool
107
#
108
# Description     : Issue a cleartool command
109
#                   Filter out many of the stupid messages
110
#
111
# Inputs          : Options and Command line
112
#                   Options:
113
#                       --Quiet     - Supress all command output
114
#
115
# Returns         : Error code
116
#
117
sub ClearTool
118
{
119
    my $quiet;
120
 
121
    #
122
    #   Scan for initial options
123
    #       --Quiet
124
    #
125
    if ( $_[0] eq '--Quiet' )
126
    {
127
        $quiet = 1;
128
        shift;
129
    }
130
 
131
    my $cmd = "cleartool @_";
132
 
133
    Verbose ("ClearTool: $cmd");
134
    open(CMD, "$cmd 2>&1 |") || Error "can't run command: $!";
135
    while (<CMD>)
136
    {
137
        #
138
        #   Filter output from the user
139
        #
140
        next if ( $quiet );
141
        unless ( $opt_verbose )
142
        {
143
            next if ( m~Making dir~ );
144
            next if ( m~End dir~ );
145
            next if ( m~Processing dir~ );
146
            next if ( m~Error~ );
147
        }
148
        print $_;
149
    }
150
    close(CMD);
151
 
152
    Verbose2 "ClearTool Exit Status: $?";
153
    return $? / 256;
154
}
155
 
156
#-------------------------------------------------------------------------------
157
#   Documentation
158
#
159
 
160
=pod
161
 
162
=pod
163
 
164
=for htmltoc    GENERAL::ClearCase::
165
 
166
=head1 NAME
167
 
168
jats ccdelete_view - Delete a clearcase views
169
 
170
=head1 SYNOPSIS
171
 
172
  jats etool ccdelete_view [options] [viewtag]+
173
 
174
 Options:
175
    -help[=n]           - brief help message
176
    -help -help         - Detailed help message
177
    -man[=n]            - Full documentation
178
    -verbose[=n]        - Verbose operation
179
    -test               - Show what will be done
180
 
181
=head1 OPTIONS
182
 
183
=over 8
184
 
185
=item B<-help[=n]>
186
 
187
Print a brief help message and exits.
188
 
189
The verbosity of the help text can be controlled by setting the help level to a
190
number in the range of 1 to 3, or by invoking the option multiple times.
191
 
192
=item B<-man[=n]>
193
 
194
Without a numeric argument this is the same as -help=3. Full help will be
195
displayed.
196
 
197
With a numeric argument, this option is the same as -help=n.
198
 
199
=item B<-verbose[=n]>
200
 
201
This option will increase the level of verbosity of the utility.
202
 
203
If an argument is provided, then it will be used to set the level, otherwise the
204
existing level will be incremented. This option may be specified multiple times.
205
 
206
=item B<-test>
207
 
208
This option will not perform any deletion. It will only show what will be done.
209
 
210
=back
211
 
212
=head1 DESCRIPTION
213
 
214
This utility is used to delete a Clear Case views. It will
215
 
216
=over 4
217
 
218
=item 1
219
 
220
Remove the view from the core of ClearCase
221
 
222
=item 2
223
 
224
Remove the view from ClearCase's registry
225
 
226
=item 3
227
 
228
Remove the view tag
229
 
230
=back
231
 
232
The removal of the view will also:
233
 
234
=over 4
235
 
236
=item *
237
 
238
Remove checked out files, both reserved and unreserved
239
 
240
=item *
241
 
242
Delete the view from the users machine, if it can be located.
243
 
244
=back
245
 
246
The utility can be used to delete views that exist only in the Clear Case
247
database after they have been removed from a users machine. Access to the
248
view is not required.
249
 
250
The utility can be used to delete one or more views.
251
 
252
The cleartool 'lsview' command can be used to display views known to Clear Case.
253
Views created by JATS are prefixed by the user's name. This can be included
254
in the command. Thus
255
 
256
    cleartool lsview SomeUser*
257
 
258
will list all views, created by JATS, created by 'SomeUser'.
259
 
260
=cut
261