Subversion Repositories DevTools

Rev

Rev 5709 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
367 dpurdie 1
########################################################################
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
367 dpurdie 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
1329 dpurdie 70
#       Allow the use of '*' under Windows with a 'glob'
367 dpurdie 71
#
1329 dpurdie 72
foreach my $view ( map { glob } @ARGV )
367 dpurdie 73
{
74
    my $uuid;
1329 dpurdie 75
 
76
    next if ( $view eq 'sandbox_dpkg_archive' );
77
    if ( -d $view )
78
    {
79
        Message ("Delete view path: $view");
80
        ClearTool( "--Quiet", "rmview $view" ) || Warning('Problem deleting view');
81
#        $opt_verbose = 1;
82
#        ClearTool( "rmview $view" );
83
        next;
84
    }
85
 
367 dpurdie 86
    #
87
    #   If the view tag still exists then delete the view the hard way
88
    #   Use 'lsview' to locate the views uuid
89
    #
90
    Verbose("Look for View Tag");
91
    my $cmd = "cleartool lsview -long $view";
92
    open(CMD, "$cmd 2>&1 |") || Error( "can't run command: $!");
93
    while (<CMD>)
94
    {
95
        #
96
        #   Filter output from the user
97
        #
98
        chomp;
99
        Verbose("lsview: $_");
100
        $uuid = $1 if ( m~^View uuid:\s+(.*)~ );
101
        $uuid = $1 if ( m~^\s*View tag uuid:\s*(.*)~ );
102
    }
103
    close(CMD);
104
 
105
    if ( $uuid )
106
    {
107
        Verbose ("UUID: $uuid");
108
        unless ( $opt_test )
109
        {
110
            ClearTool( "--Quiet", "rmview -force -all -uuid $uuid" );
111
            ClearTool( "--Quiet", "unregister -view -uuid $uuid" );
112
            ClearTool( "--Quiet", "rmtag -view -all $view" );
113
        }
114
    }
115
}
116
 
117
#-------------------------------------------------------------------------------
118
# Function        : ClearTool
119
#
120
# Description     : Issue a cleartool command
121
#                   Filter out many of the stupid messages
122
#
123
# Inputs          : Options and Command line
124
#                   Options:
125
#                       --Quiet     - Supress all command output
126
#
127
# Returns         : Error code
128
#
129
sub ClearTool
130
{
131
    my $quiet;
132
 
133
    #
134
    #   Scan for initial options
135
    #       --Quiet
136
    #
137
    if ( $_[0] eq '--Quiet' )
138
    {
139
        $quiet = 1;
140
        shift;
141
    }
142
 
143
    my $cmd = "cleartool @_";
144
 
145
    Verbose ("ClearTool: $cmd");
146
    open(CMD, "$cmd 2>&1 |") || Error "can't run command: $!";
147
    while (<CMD>)
148
    {
149
        #
150
        #   Filter output from the user
151
        #
152
        next if ( $quiet );
153
        unless ( $opt_verbose )
154
        {
155
            next if ( m~Making dir~ );
156
            next if ( m~End dir~ );
157
            next if ( m~Processing dir~ );
158
            next if ( m~Error~ );
159
        }
160
        print $_;
161
    }
162
    close(CMD);
163
 
164
    Verbose2 "ClearTool Exit Status: $?";
165
    return $? / 256;
166
}
167
 
168
#-------------------------------------------------------------------------------
169
#   Documentation
170
#
171
 
172
=pod
173
 
174
=pod
175
 
176
=for htmltoc    GENERAL::ClearCase::
177
 
178
=head1 NAME
179
 
180
jats ccdelete_view - Delete a clearcase views
181
 
182
=head1 SYNOPSIS
183
 
1329 dpurdie 184
  jats etool ccdelete_view [options] [viewtag|viewpath]+
367 dpurdie 185
 
186
 Options:
187
    -help[=n]           - brief help message
188
    -help -help         - Detailed help message
189
    -man[=n]            - Full documentation
190
    -verbose[=n]        - Verbose operation
191
    -test               - Show what will be done
192
 
193
=head1 OPTIONS
194
 
195
=over 8
196
 
197
=item B<-help[=n]>
198
 
199
Print a brief help message and exits.
200
 
201
The verbosity of the help text can be controlled by setting the help level to a
202
number in the range of 1 to 3, or by invoking the option multiple times.
203
 
204
=item B<-man[=n]>
205
 
206
Without a numeric argument this is the same as -help=3. Full help will be
207
displayed.
208
 
209
With a numeric argument, this option is the same as -help=n.
210
 
211
=item B<-verbose[=n]>
212
 
213
This option will increase the level of verbosity of the utility.
214
 
215
If an argument is provided, then it will be used to set the level, otherwise the
216
existing level will be incremented. This option may be specified multiple times.
217
 
218
=item B<-test>
219
 
220
This option will not perform any deletion. It will only show what will be done.
221
 
222
=back
223
 
224
=head1 DESCRIPTION
225
 
1329 dpurdie 226
This utility is used to delete a Clear Case views. If the user provides a valid
227
directory then the view store and view path will be removed, otherwise the tool
228
assumes that a viewtag has been provided. It will:
367 dpurdie 229
 
230
=over 4
231
 
232
=item 1
233
 
234
Remove the view from the core of ClearCase
235
 
236
=item 2
237
 
238
Remove the view from ClearCase's registry
239
 
240
=item 3
241
 
242
Remove the view tag
243
 
244
=back
245
 
246
The removal of the view will also:
247
 
248
=over 4
249
 
250
=item *
251
 
252
Remove checked out files, both reserved and unreserved
253
 
254
=item *
255
 
256
Delete the view from the users machine, if it can be located.
257
 
258
=back
259
 
260
The utility can be used to delete views that exist only in the Clear Case
261
database after they have been removed from a users machine. Access to the
262
view is not required.
263
 
264
The utility can be used to delete one or more views.
265
 
266
The cleartool 'lsview' command can be used to display views known to Clear Case.
267
Views created by JATS are prefixed by the user's name. This can be included
268
in the command. Thus
269
 
270
    cleartool lsview SomeUser*
271
 
272
will list all views, created by JATS, created by 'SomeUser'.
273
 
274
=cut
275