validate_repo.in revision 1.1.1.1.2.2 1 1.1.1.1.2.2 jym #! @PERL@ -w
2 1.1.1.1.2.2 jym ########################################################################
3 1.1.1.1.2.2 jym #
4 1.1.1.1.2.2 jym # Copyright (c) 2000, 2001 by Donald Sharp <sharpd (at] cisco.com>
5 1.1.1.1.2.2 jym # All Rights Reserved
6 1.1.1.1.2.2 jym #
7 1.1.1.1.2.2 jym # Some portions Copyright (c) 2002, 2003 by
8 1.1.1.1.2.2 jym # Derek R. Price <mailto:derek (at] ximbiot.com>
9 1.1.1.1.2.2 jym # & Ximbiot <http://ximbiot.com>.
10 1.1.1.1.2.2 jym # All rights reserved.
11 1.1.1.1.2.2 jym #
12 1.1.1.1.2.2 jym # Permission is granted to copy and/or distribute this file, with or
13 1.1.1.1.2.2 jym # without modifications, provided this notice is preserved.
14 1.1.1.1.2.2 jym #
15 1.1.1.1.2.2 jym # This program is free software; you can redistribute it and/or modify
16 1.1.1.1.2.2 jym # it under the terms of the GNU General Public License as published by
17 1.1.1.1.2.2 jym # the Free Software Foundation; either version 2, or (at your option)
18 1.1.1.1.2.2 jym # any later version.
19 1.1.1.1.2.2 jym #
20 1.1.1.1.2.2 jym # This program is distributed in the hope that it will be useful,
21 1.1.1.1.2.2 jym # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 1.1.1.1.2.2 jym # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 1.1.1.1.2.2 jym # GNU General Public License for more details.
24 1.1.1.1.2.2 jym #
25 1.1.1.1.2.2 jym ########################################################################
26 1.1.1.1.2.2 jym
27 1.1.1.1.2.2 jym =head1 validate_repo.pl
28 1.1.1.1.2.2 jym
29 1.1.1.1.2.2 jym Script to check the integrity of the Repository.
30 1.1.1.1.2.2 jym
31 1.1.1.1.2.2 jym =head1 SYNOPSIS
32 1.1.1.1.2.2 jym
33 1.1.1.1.2.2 jym perldoc validate_repo.pl
34 1.1.1.1.2.2 jym validate_repo.pl --help [--verbose!]
35 1.1.1.1.2.2 jym validate_repo.pl [--verbose!] [--cvsroot=CVSROOT] [--exec=SCRIPT]...
36 1.1.1.1.2.2 jym [--all-revisions!] [module]...
37 1.1.1.1.2.2 jym
38 1.1.1.1.2.2 jym =head1 DESCRIPTION
39 1.1.1.1.2.2 jym
40 1.1.1.1.2.2 jym This script will search through a repository and determine if any of the
41 1.1.1.1.2.2 jym files in it are corrupted.
42 1.1.1.1.2.2 jym
43 1.1.1.1.2.2 jym This is normally accomplished by checking out all I<important> revisions, where
44 1.1.1.1.2.2 jym I<important> revisions are defined as the smallest set which, when checked out,
45 1.1.1.1.2.2 jym will cause each and every revision's integrity to be verified. This resolves
46 1.1.1.1.2.2 jym to the most recent revision on each branch and the first and last revisions on
47 1.1.1.1.2.2 jym the trunk.
48 1.1.1.1.2.2 jym
49 1.1.1.1.2.2 jym Please do not run this script inside of the repository itself. This will cause
50 1.1.1.1.2.2 jym it too fail.
51 1.1.1.1.2.2 jym
52 1.1.1.1.2.2 jym =head1 OPTIONS
53 1.1.1.1.2.2 jym
54 1.1.1.1.2.2 jym =over
55 1.1.1.1.2.2 jym
56 1.1.1.1.2.2 jym =item C<--help>
57 1.1.1.1.2.2 jym
58 1.1.1.1.2.2 jym Print this very help text (or, with C<--verbose>, act like
59 1.1.1.1.2.2 jym C<perldoc validate_repo.pl>).
60 1.1.1.1.2.2 jym
61 1.1.1.1.2.2 jym =item C<-a> or C<--all-revisions>
62 1.1.1.1.2.2 jym
63 1.1.1.1.2.2 jym Check out each and every revision rather than just the I<important> ones.
64 1.1.1.1.2.2 jym This flag is useful with C<--exec> to execute the C<SCRIPT> (from C<--exec>
65 1.1.1.1.2.2 jym below) on a checked out copy of each and every revision.
66 1.1.1.1.2.2 jym
67 1.1.1.1.2.2 jym =item C<-d> or C<--cvsroot=CVSROOT>
68 1.1.1.1.2.2 jym
69 1.1.1.1.2.2 jym Use repository specified by C<CVSROOT>. Defaults to the contents of the
70 1.1.1.1.2.2 jym F<./CVS/Root> file when it exists and is readable, then to the contents of the
71 1.1.1.1.2.2 jym C<$CVSROOT> environment variable when it is set and non-empty.
72 1.1.1.1.2.2 jym
73 1.1.1.1.2.2 jym =item C<-e> or C<--exec=SCRIPT>
74 1.1.1.1.2.2 jym
75 1.1.1.1.2.2 jym Execute (as from command prompt) C<SCRIPT> if it exists as a file, is readable,
76 1.1.1.1.2.2 jym and is executable, or evaluate (as a perl script) C<SCRIPT> for a checked out
77 1.1.1.1.2.2 jym copy of each I<important> revision of each RCS archive in CVSROOT. Executed
78 1.1.1.1.2.2 jym scripts are passed C<CVSROOT FILE REVISION FNO>, where C<CVSROOT> is what
79 1.1.1.1.2.2 jym you'd think, C<FILE> is the path to the file relative to C<CVSROOT> and
80 1.1.1.1.2.2 jym suitable for use as an argument to C<cvs co>, C<cvs rlog>, and so on,
81 1.1.1.1.2.2 jym C<REVISION> is the revision of the checked out file, and C<FNO> is the file
82 1.1.1.1.2.2 jym number of the open, read-only file descriptor containing the checked out
83 1.1.1.1.2.2 jym contents of revision C<REVISION> of C<FILE>. An evaluated C<SCRIPT> will find
84 1.1.1.1.2.2 jym the same four arguments in the same order in C<@_>, except that C<FNO> will be
85 1.1.1.1.2.2 jym an open file handle.
86 1.1.1.1.2.2 jym
87 1.1.1.1.2.2 jym With C<--all-revisions>, execute or evaluate C<SCRIPT> for a checked out
88 1.1.1.1.2.2 jym version of each revsion in the RCS archive.
89 1.1.1.1.2.2 jym
90 1.1.1.1.2.2 jym =item C<-v> or C<--verbose>
91 1.1.1.1.2.2 jym
92 1.1.1.1.2.2 jym Print verbose debugging information (or, when specified with C<--help>, act
93 1.1.1.1.2.2 jym like C<perldoc validate_repo.pl>).
94 1.1.1.1.2.2 jym
95 1.1.1.1.2.2 jym =head1 ARGUMENTS
96 1.1.1.1.2.2 jym
97 1.1.1.1.2.2 jym =over
98 1.1.1.1.2.2 jym
99 1.1.1.1.2.2 jym =item C<modules>
100 1.1.1.1.2.2 jym
101 1.1.1.1.2.2 jym The module in the repository to examine. Defaults to the contents of the
102 1.1.1.1.2.2 jym F<./CVS/Repository> file when it exists and is readable, then to F<.>
103 1.1.1.1.2.2 jym (all modules).
104 1.1.1.1.2.2 jym
105 1.1.1.1.2.2 jym =head1 EXAMPLES
106 1.1.1.1.2.2 jym
107 1.1.1.1.2.2 jym setenv CVSROOT /release/111/cvs
108 1.1.1.1.2.2 jym validate_repo.pl
109 1.1.1.1.2.2 jym
110 1.1.1.1.2.2 jym
111 1.1.1.1.2.2 jym validate_repo.pl -d /another/cvsroot --verbose --exec '
112 1.1.1.1.2.2 jym system "grep \"This string means Im a bad, bad file!\" <&"
113 1.1.1.1.2.2 jym . fileno( $_[3] )
114 1.1.1.1.2.2 jym . ">/dev/null"
115 1.1.1.1.2.2 jym or die "Revision $_[2] of $_[0]/$_[1],v is bad, bad, bad!"'
116 1.1.1.1.2.2 jym
117 1.1.1.1.2.2 jym =head1 SEE ALSO
118 1.1.1.1.2.2 jym
119 1.1.1.1.2.2 jym None.
120 1.1.1.1.2.2 jym
121 1.1.1.1.2.2 jym =cut
122 1.1.1.1.2.2 jym
123 1.1.1.1.2.2 jym ######################################################################
124 1.1.1.1.2.2 jym # MODULES #
125 1.1.1.1.2.2 jym ######################################################################
126 1.1.1.1.2.2 jym use strict;
127 1.1.1.1.2.2 jym
128 1.1.1.1.2.2 jym use Fcntl qw( F_GETFD F_SETFD );
129 1.1.1.1.2.2 jym use File::Find;
130 1.1.1.1.2.2 jym use File::Basename;
131 1.1.1.1.2.2 jym use File::Path;
132 1.1.1.1.2.2 jym use File::Spec;
133 1.1.1.1.2.2 jym use Getopt::Long;
134 1.1.1.1.2.2 jym use IO::File;
135 1.1.1.1.2.2 jym use Pod::Usage;
136 1.1.1.1.2.2 jym
137 1.1.1.1.2.2 jym ######################################################################
138 1.1.1.1.2.2 jym # GLOBALS #
139 1.1.1.1.2.2 jym ######################################################################
140 1.1.1.1.2.2 jym
141 1.1.1.1.2.2 jym use vars qw(
142 1.1.1.1.2.2 jym $all_revisions
143 1.1.1.1.2.2 jym $cvsroot
144 1.1.1.1.2.2 jym @extra_files
145 1.1.1.1.2.2 jym @ignore_files
146 1.1.1.1.2.2 jym $ignored_files
147 1.1.1.1.2.2 jym @invalid_revs
148 1.1.1.1.2.2 jym @list_of_broken_files
149 1.1.1.1.2.2 jym @scripts
150 1.1.1.1.2.2 jym $total_files
151 1.1.1.1.2.2 jym $total_interesting_revisions
152 1.1.1.1.2.2 jym $total_revisions
153 1.1.1.1.2.2 jym $verbose
154 1.1.1.1.2.2 jym );
155 1.1.1.1.2.2 jym
156 1.1.1.1.2.2 jym
157 1.1.1.1.2.2 jym
158 1.1.1.1.2.2 jym ######################################################################
159 1.1.1.1.2.2 jym # SUBROUTINES #
160 1.1.1.1.2.2 jym ######################################################################
161 1.1.1.1.2.2 jym
162 1.1.1.1.2.2 jym ######################################################################
163 1.1.1.1.2.2 jym #
164 1.1.1.1.2.2 jym # NAME :
165 1.1.1.1.2.2 jym # main
166 1.1.1.1.2.2 jym #
167 1.1.1.1.2.2 jym # PURPOSE :
168 1.1.1.1.2.2 jym # To search the repository for broken files
169 1.1.1.1.2.2 jym #
170 1.1.1.1.2.2 jym # PARAMETERS :
171 1.1.1.1.2.2 jym # NONE
172 1.1.1.1.2.2 jym #
173 1.1.1.1.2.2 jym # GLOBALS :
174 1.1.1.1.2.2 jym # $cvsroot - The CVS repository to search through.
175 1.1.1.1.2.2 jym # $ENV{ CVSROOT } - The default CVS repository to search through.
176 1.1.1.1.2.2 jym # @list_of_broken_files - The list of files that need to
177 1.1.1.1.2.2 jym # be fixed.
178 1.1.1.1.2.2 jym # $verbose - is verbose mode on?
179 1.1.1.1.2.2 jym # @scripts - scripts to run on checked out files.
180 1.1.1.1.2.2 jym # $total_revisions - The number of revisions considered
181 1.1.1.1.2.2 jym # $total_interesting_revisions - The number of revisions used
182 1.1.1.1.2.2 jym # $total_files - The total number of files looked at.
183 1.1.1.1.2.2 jym #
184 1.1.1.1.2.2 jym # RETURNS :
185 1.1.1.1.2.2 jym # A list of broken files
186 1.1.1.1.2.2 jym #
187 1.1.1.1.2.2 jym # COMMENTS :
188 1.1.1.1.2.2 jym # Do not run this script inside the repository. Choose
189 1.1.1.1.2.2 jym # a nice safe spot( like /tmp ) outside of the repository.
190 1.1.1.1.2.2 jym #
191 1.1.1.1.2.2 jym ######################################################################
192 1.1.1.1.2.2 jym sub main
193 1.1.1.1.2.2 jym {
194 1.1.1.1.2.2 jym my $help;
195 1.1.1.1.2.2 jym
196 1.1.1.1.2.2 jym $ignored_files = 0;
197 1.1.1.1.2.2 jym $total_files = 0;
198 1.1.1.1.2.2 jym $total_interesting_revisions = 0;
199 1.1.1.1.2.2 jym $total_revisions = 0;
200 1.1.1.1.2.2 jym
201 1.1.1.1.2.2 jym Getopt::Long::Configure( "bundling" );
202 1.1.1.1.2.2 jym unless( GetOptions(
203 1.1.1.1.2.2 jym 'all-revisions|a!' => \$all_revisions,
204 1.1.1.1.2.2 jym 'cvsroot|d=s' => \$cvsroot,
205 1.1.1.1.2.2 jym 'exec|e=s' => \@scripts,
206 1.1.1.1.2.2 jym 'help|h|?!' => \$help,
207 1.1.1.1.2.2 jym 'verbose|v!' => \$verbose
208 1.1.1.1.2.2 jym )
209 1.1.1.1.2.2 jym )
210 1.1.1.1.2.2 jym {
211 1.1.1.1.2.2 jym pod2usage( 2 );
212 1.1.1.1.2.2 jym exit 2;
213 1.1.1.1.2.2 jym }
214 1.1.1.1.2.2 jym
215 1.1.1.1.2.2 jym pod2usage( -exitval => 2,
216 1.1.1.1.2.2 jym -verbose => $verbose ? 2 : 1,
217 1.1.1.1.2.2 jym -output => \*STDOUT )
218 1.1.1.1.2.2 jym if $help;
219 1.1.1.1.2.2 jym
220 1.1.1.1.2.2 jym verbose( "Verbose Mode Turned On\n" );
221 1.1.1.1.2.2 jym
222 1.1.1.1.2.2 jym if( !$cvsroot && -f "CVS/Root" && -r "CVS/Root" )
223 1.1.1.1.2.2 jym {
224 1.1.1.1.2.2 jym my $file = new IO::File "< CVS/Root";
225 1.1.1.1.2.2 jym $cvsroot = $file->getline;
226 1.1.1.1.2.2 jym chomp $cvsroot;
227 1.1.1.1.2.2 jym }
228 1.1.1.1.2.2 jym $cvsroot = $ENV{'CVSROOT'} unless $cvsroot;
229 1.1.1.1.2.2 jym pod2usage( "error: Must set CVSROOT" ) unless $cvsroot;
230 1.1.1.1.2.2 jym
231 1.1.1.1.2.2 jym if( $cvsroot =~ /^:\w+:/ && $cvsroot !~ /^:local:/
232 1.1.1.1.2.2 jym || $cvsroot =~ /@/ )
233 1.1.1.1.2.2 jym {
234 1.1.1.1.2.2 jym print STDERR "CVSROOT must be :local:\n";
235 1.1.1.1.2.2 jym exit 2;
236 1.1.1.1.2.2 jym }
237 1.1.1.1.2.2 jym
238 1.1.1.1.2.2 jym for (@scripts)
239 1.1.1.1.2.2 jym {
240 1.1.1.1.2.2 jym $_ = File::Spec->rel2abs( $_ ) unless /\n/ || !-x $_;
241 1.1.1.1.2.2 jym }
242 1.1.1.1.2.2 jym
243 1.1.1.1.2.2 jym
244 1.1.1.1.2.2 jym if( !scalar( @ARGV ) && -f "CVS/Repository" && -r "CVS/Repository" )
245 1.1.1.1.2.2 jym {
246 1.1.1.1.2.2 jym my $file = new IO::File "< CVS/Repository";
247 1.1.1.1.2.2 jym my $module = $file->getline;
248 1.1.1.1.2.2 jym chomp $module;
249 1.1.1.1.2.2 jym push @ARGV, $module;
250 1.1.1.1.2.2 jym }
251 1.1.1.1.2.2 jym
252 1.1.1.1.2.2 jym push @ARGV, "." unless( scalar @ARGV );
253 1.1.1.1.2.2 jym
254 1.1.1.1.2.2 jym foreach my $directory_to_look_at ( @ARGV )
255 1.1.1.1.2.2 jym {
256 1.1.1.1.2.2 jym $directory_to_look_at = File::Spec->catfile( $cvsroot,
257 1.1.1.1.2.2 jym $directory_to_look_at );
258 1.1.1.1.2.2 jym
259 1.1.1.1.2.2 jym my $sym_count = 0;
260 1.1.1.1.2.2 jym while( -l $directory_to_look_at )
261 1.1.1.1.2.2 jym {
262 1.1.1.1.2.2 jym $directory_to_look_at = readlink( $directory_to_look_at );
263 1.1.1.1.2.2 jym $sym_count += 1;
264 1.1.1.1.2.2 jym die( "Encountered too many symlinks for CVSROOT ($cvsroot)\n" )
265 1.1.1.1.2.2 jym if( $sym_count > 5 );
266 1.1.1.1.2.2 jym }
267 1.1.1.1.2.2 jym
268 1.1.1.1.2.2 jym # Remove indirections.
269 1.1.1.1.2.2 jym $directory_to_look_at =~ s#(/+.)*$##o;
270 1.1.1.1.2.2 jym
271 1.1.1.1.2.2 jym verbose( "Processing: $directory_to_look_at\n" );
272 1.1.1.1.2.2 jym @ignore_files = get_ignore_files_from_cvsroot( $directory_to_look_at );
273 1.1.1.1.2.2 jym find( \&process_file, $directory_to_look_at );
274 1.1.1.1.2.2 jym }
275 1.1.1.1.2.2 jym
276 1.1.1.1.2.2 jym print "List of corrupted files\n" if @list_of_broken_files;
277 1.1.1.1.2.2 jym foreach my $broken ( @list_of_broken_files )
278 1.1.1.1.2.2 jym {
279 1.1.1.1.2.2 jym print( "**** File: $broken\n" );
280 1.1.1.1.2.2 jym }
281 1.1.1.1.2.2 jym
282 1.1.1.1.2.2 jym print "List of Files containing invalid revisions:\n"
283 1.1.1.1.2.2 jym if @invalid_revs;
284 1.1.1.1.2.2 jym foreach ( @invalid_revs )
285 1.1.1.1.2.2 jym {
286 1.1.1.1.2.2 jym print( "**** File: ($_->{'rev'}) $_->{'file'}\n" );
287 1.1.1.1.2.2 jym }
288 1.1.1.1.2.2 jym
289 1.1.1.1.2.2 jym print "List of Files That Don't belong in Repository:\n"
290 1.1.1.1.2.2 jym if @extra_files;
291 1.1.1.1.2.2 jym foreach my $extra ( @extra_files )
292 1.1.1.1.2.2 jym {
293 1.1.1.1.2.2 jym print( "**** File: $extra\n" );
294 1.1.1.1.2.2 jym }
295 1.1.1.1.2.2 jym print( "Total Files: $total_files Corrupted files: "
296 1.1.1.1.2.2 jym . scalar( @list_of_broken_files )
297 1.1.1.1.2.2 jym . " Invalid revs: "
298 1.1.1.1.2.2 jym . scalar( @invalid_revs )
299 1.1.1.1.2.2 jym . " Extra files: "
300 1.1.1.1.2.2 jym . scalar( @extra_files )
301 1.1.1.1.2.2 jym . " Ignored Files: $ignored_files\n" );
302 1.1.1.1.2.2 jym print( "Total Revisions: $total_revisions Interesting Revisions: $total_interesting_revisions\n" );
303 1.1.1.1.2.2 jym }
304 1.1.1.1.2.2 jym
305 1.1.1.1.2.2 jym
306 1.1.1.1.2.2 jym
307 1.1.1.1.2.2 jym sub verbose
308 1.1.1.1.2.2 jym {
309 1.1.1.1.2.2 jym print STDERR @_ if $verbose;
310 1.1.1.1.2.2 jym }
311 1.1.1.1.2.2 jym
312 1.1.1.1.2.2 jym
313 1.1.1.1.2.2 jym
314 1.1.1.1.2.2 jym ######################################################################
315 1.1.1.1.2.2 jym #
316 1.1.1.1.2.2 jym # NAME :
317 1.1.1.1.2.2 jym # process_file
318 1.1.1.1.2.2 jym #
319 1.1.1.1.2.2 jym # PURPOSE :
320 1.1.1.1.2.2 jym # This function is called by the find function, its purpose
321 1.1.1.1.2.2 jym # is to decide if it is important to look at a file or not. When
322 1.1.1.1.2.2 jym # a file is important, we log it or call &look_at_cvs_file on it.
323 1.1.1.1.2.2 jym #
324 1.1.1.1.2.2 jym # ALGORITHM
325 1.1.1.1.2.2 jym # 1) If the file is an archive file, we call &look_at_cvs_file on
326 1.1.1.1.2.2 jym # it.
327 1.1.1.1.2.2 jym # 2) Else, if the file is not in the ignore list, we store its name
328 1.1.1.1.2.2 jym # for later.
329 1.1.1.1.2.2 jym #
330 1.1.1.1.2.2 jym # PARAMETERS :
331 1.1.1.1.2.2 jym # NONE
332 1.1.1.1.2.2 jym #
333 1.1.1.1.2.2 jym # GLOBALS :
334 1.1.1.1.2.2 jym # $cvsroot - The CVS repository to search through
335 1.1.1.1.2.2 jym # @ignore_files - File patterns we can afford to ignore.
336 1.1.1.1.2.2 jym # $File::Find::name - The absolute path of the file being examined.
337 1.1.1.1.2.2 jym #
338 1.1.1.1.2.2 jym # RETURNS :
339 1.1.1.1.2.2 jym # NONE
340 1.1.1.1.2.2 jym #
341 1.1.1.1.2.2 jym # COMMENTS :
342 1.1.1.1.2.2 jym # NONE
343 1.1.1.1.2.2 jym #
344 1.1.1.1.2.2 jym ######################################################################
345 1.1.1.1.2.2 jym sub process_file
346 1.1.1.1.2.2 jym {
347 1.1.1.1.2.2 jym if( ! -d $File::Find::name )
348 1.1.1.1.2.2 jym {
349 1.1.1.1.2.2 jym my $path = $File::Find::name;
350 1.1.1.1.2.2 jym $path =~ s#^$cvsroot/(\./)*##;
351 1.1.1.1.2.2 jym $total_files++;
352 1.1.1.1.2.2 jym
353 1.1.1.1.2.2 jym verbose( "Examining `$path'\n" );
354 1.1.1.1.2.2 jym
355 1.1.1.1.2.2 jym if( $path =~ s/,v$// )
356 1.1.1.1.2.2 jym {
357 1.1.1.1.2.2 jym look_at_cvs_file( $path );
358 1.1.1.1.2.2 jym }
359 1.1.1.1.2.2 jym elsif( !grep { $path =~ $_ } @ignore_files )
360 1.1.1.1.2.2 jym {
361 1.1.1.1.2.2 jym push @extra_files, $path;
362 1.1.1.1.2.2 jym verbose( "Adding unrecognized file `$path' to corrupted list.\n" );
363 1.1.1.1.2.2 jym }
364 1.1.1.1.2.2 jym else
365 1.1.1.1.2.2 jym {
366 1.1.1.1.2.2 jym $ignored_files++;
367 1.1.1.1.2.2 jym verbose( "Ignoring `$path'\n" );
368 1.1.1.1.2.2 jym }
369 1.1.1.1.2.2 jym }
370 1.1.1.1.2.2 jym }
371 1.1.1.1.2.2 jym
372 1.1.1.1.2.2 jym ######################################################################
373 1.1.1.1.2.2 jym #
374 1.1.1.1.2.2 jym # NAME :
375 1.1.1.1.2.2 jym # look_at_cvs_file
376 1.1.1.1.2.2 jym #
377 1.1.1.1.2.2 jym # PURPOSE :
378 1.1.1.1.2.2 jym # To decide if a file is broken or not. The algorithm is:
379 1.1.1.1.2.2 jym # a) Get the revision history for the file.
380 1.1.1.1.2.2 jym # - If that fails the file is broken, save the fact
381 1.1.1.1.2.2 jym # and continue processing other files.
382 1.1.1.1.2.2 jym # - If that succeeds we have a list of revisions.
383 1.1.1.1.2.2 jym # b) For each revision call &check_revision on the file.
384 1.1.1.1.2.2 jym # - If that fails the file is broken, save the fact
385 1.1.1.1.2.2 jym # and continue processing other files.
386 1.1.1.1.2.2 jym # c) Continue on
387 1.1.1.1.2.2 jym #
388 1.1.1.1.2.2 jym # PARAMETERS :
389 1.1.1.1.2.2 jym # $file - The path of the file to look at, relative to $cvsroot and
390 1.1.1.1.2.2 jym # suitable for use as an argument to `cvs co', `cvs rlog', and
391 1.1.1.1.2.2 jym # the rest of CVS's r* commands.
392 1.1.1.1.2.2 jym #
393 1.1.1.1.2.2 jym # GLOBALS :
394 1.1.1.1.2.2 jym # NONE
395 1.1.1.1.2.2 jym #
396 1.1.1.1.2.2 jym # RETURNS :
397 1.1.1.1.2.2 jym # NONE
398 1.1.1.1.2.2 jym #
399 1.1.1.1.2.2 jym # COMMENTS :
400 1.1.1.1.2.2 jym # We have to handle Attic files in a special manner.
401 1.1.1.1.2.2 jym # Basically remove the Attic from the string if it
402 1.1.1.1.2.2 jym # exists at the end of the $path variable.
403 1.1.1.1.2.2 jym #
404 1.1.1.1.2.2 jym ######################################################################
405 1.1.1.1.2.2 jym sub look_at_cvs_file
406 1.1.1.1.2.2 jym {
407 1.1.1.1.2.2 jym my( $file ) = @_;
408 1.1.1.1.2.2 jym my( $name, $path ) = fileparse( $file );
409 1.1.1.1.2.2 jym
410 1.1.1.1.2.2 jym $file = $path . $name if $path =~ s#Attic/$##;
411 1.1.1.1.2.2 jym
412 1.1.1.1.2.2 jym my( $finfo, $rinfo ) = get_history( $file );
413 1.1.1.1.2.2 jym
414 1.1.1.1.2.2 jym unless( defined $rinfo )
415 1.1.1.1.2.2 jym {
416 1.1.1.1.2.2 jym verbose( "\t`$file' is corrupted. It was determined to contain no\n"
417 1.1.1.1.2.2 jym . "\trevisions via a cvs rlog command\n" );
418 1.1.1.1.2.2 jym push( @list_of_broken_files, $file );
419 1.1.1.1.2.2 jym return();
420 1.1.1.1.2.2 jym }
421 1.1.1.1.2.2 jym
422 1.1.1.1.2.2 jym my @int_revisions =
423 1.1.1.1.2.2 jym $all_revisions ? keys %$rinfo
424 1.1.1.1.2.2 jym : find_interesting_revisions( keys %$rinfo );
425 1.1.1.1.2.2 jym
426 1.1.1.1.2.2 jym foreach my $revision ( @int_revisions )
427 1.1.1.1.2.2 jym {
428 1.1.1.1.2.2 jym verbose( "\t\tLooking at Revision: $revision\n" );
429 1.1.1.1.2.2 jym if( !check_revision( $file, $revision, $finfo, $rinfo ) )
430 1.1.1.1.2.2 jym {
431 1.1.1.1.2.2 jym verbose( "\t$file is corrupted in revision: $revision\n" );
432 1.1.1.1.2.2 jym push( @list_of_broken_files, $file );
433 1.1.1.1.2.2 jym return();
434 1.1.1.1.2.2 jym }
435 1.1.1.1.2.2 jym }
436 1.1.1.1.2.2 jym }
437 1.1.1.1.2.2 jym
438 1.1.1.1.2.2 jym ######################################################################
439 1.1.1.1.2.2 jym #
440 1.1.1.1.2.2 jym # NAME :
441 1.1.1.1.2.2 jym # get_history
442 1.1.1.1.2.2 jym #
443 1.1.1.1.2.2 jym # PURPOSE :
444 1.1.1.1.2.2 jym # To retrieve an array of revision numbers.
445 1.1.1.1.2.2 jym #
446 1.1.1.1.2.2 jym # PARAMETERS :
447 1.1.1.1.2.2 jym # $file - The file to retrieve the revision numbers for
448 1.1.1.1.2.2 jym #
449 1.1.1.1.2.2 jym # GLOBALS :
450 1.1.1.1.2.2 jym # $cvsroot - the CVSROOT we are examining
451 1.1.1.1.2.2 jym #
452 1.1.1.1.2.2 jym # RETURNS :
453 1.1.1.1.2.2 jym # On Success - A hash of revision info, indexed by revision numbers.
454 1.1.1.1.2.2 jym # On Failure - undef.
455 1.1.1.1.2.2 jym #
456 1.1.1.1.2.2 jym # COMMENTS :
457 1.1.1.1.2.2 jym # The $_ is saved off because The File::find functionality
458 1.1.1.1.2.2 jym # expects the $_ to not have been changed.
459 1.1.1.1.2.2 jym # The -N option for the rlog command means to spit out
460 1.1.1.1.2.2 jym # tags or branch names.
461 1.1.1.1.2.2 jym #
462 1.1.1.1.2.2 jym ######################################################################
463 1.1.1.1.2.2 jym sub get_history
464 1.1.1.1.2.2 jym {
465 1.1.1.1.2.2 jym my( $file ) = @_;
466 1.1.1.1.2.2 jym $file =~ s/(["\$`\\])/\\$1/g;
467 1.1.1.1.2.2 jym my %finfo; # Info about the file.
468 1.1.1.1.2.2 jym my %rinfo; # Info about revisions in the file.
469 1.1.1.1.2.2 jym my $revision;
470 1.1.1.1.2.2 jym
471 1.1.1.1.2.2 jym my $fh = new IO::File( "cvs -d $cvsroot rlog -N \"$file\""
472 1.1.1.1.2.2 jym . ($verbose ? "" : " 2>&1") . " |" )
473 1.1.1.1.2.2 jym or die( "unable to run `cvs rlog', help" );
474 1.1.1.1.2.2 jym
475 1.1.1.1.2.2 jym my $ignore = -1;
476 1.1.1.1.2.2 jym while( my $line = $fh->getline )
477 1.1.1.1.2.2 jym {
478 1.1.1.1.2.2 jym if( $ignore == 1 )
479 1.1.1.1.2.2 jym {
480 1.1.1.1.2.2 jym if( ( $revision ) = $line =~ /^revision (.*?)(\tlocked by: \S+;)?$/ )
481 1.1.1.1.2.2 jym {
482 1.1.1.1.2.2 jym unless($revision =~ m/^\d+\.\d+(?:\.\d+\.\d+)*$/)
483 1.1.1.1.2.2 jym {
484 1.1.1.1.2.2 jym push @invalid_revs, { 'file' => $file, 'rev' => $revision };
485 1.1.1.1.2.2 jym verbose( "Adding invalid revision `$revision' of file `$file' to invalid revs list.\n" );
486 1.1.1.1.2.2 jym }
487 1.1.1.1.2.2 jym
488 1.1.1.1.2.2 jym $ignore++;
489 1.1.1.1.2.2 jym next;
490 1.1.1.1.2.2 jym }
491 1.1.1.1.2.2 jym
492 1.1.1.1.2.2 jym # We require ---- before a ^revision tag, not a revision
493 1.1.1.1.2.2 jym # after every ----.
494 1.1.1.1.2.2 jym $ignore = 0;
495 1.1.1.1.2.2 jym }
496 1.1.1.1.2.2 jym if( $ignore == 2 )
497 1.1.1.1.2.2 jym {
498 1.1.1.1.2.2 jym if( my ( $date, $author, $state ) =
499 1.1.1.1.2.2 jym $line =~ /^date: (\S+ \S+); author: ([^;]+); state: (\S+);/ )
500 1.1.1.1.2.2 jym {
501 1.1.1.1.2.2 jym $rinfo{$revision} =
502 1.1.1.1.2.2 jym {
503 1.1.1.1.2.2 jym 'date' => $date,
504 1.1.1.1.2.2 jym 'author' => $author,
505 1.1.1.1.2.2 jym 'state' => $state
506 1.1.1.1.2.2 jym }
507 1.1.1.1.2.2 jym }
508 1.1.1.1.2.2 jym else
509 1.1.1.1.2.2 jym {
510 1.1.1.1.2.2 jym die "Couldn't read date/author/state for revision $revision\n"
511 1.1.1.1.2.2 jym . "of $file from `cvs rlog'.\n"
512 1.1.1.1.2.2 jym . "line = $line";
513 1.1.1.1.2.2 jym }
514 1.1.1.1.2.2 jym $ignore = 0;
515 1.1.1.1.2.2 jym next;
516 1.1.1.1.2.2 jym }
517 1.1.1.1.2.2 jym if( $ignore == -1 )
518 1.1.1.1.2.2 jym {
519 1.1.1.1.2.2 jym # Until we find the first ---- below, we can read general file info
520 1.1.1.1.2.2 jym if( my ( $kwmode ) =
521 1.1.1.1.2.2 jym $line =~ /^keyword substitution: (\S+)$/ )
522 1.1.1.1.2.2 jym {
523 1.1.1.1.2.2 jym $finfo{'kwmode'} = $kwmode;
524 1.1.1.1.2.2 jym next;
525 1.1.1.1.2.2 jym }
526 1.1.1.1.2.2 jym }
527 1.1.1.1.2.2 jym # rlog outputs a "----" line before the actual revision
528 1.1.1.1.2.2 jym # without this we'll pick up peoples comments if they
529 1.1.1.1.2.2 jym # happen to start with revision
530 1.1.1.1.2.2 jym if( $line =~ /^----------------------------$/ )
531 1.1.1.1.2.2 jym {
532 1.1.1.1.2.2 jym # Catch this case when $ignore == -1 or 0
533 1.1.1.1.2.2 jym $ignore = 1;
534 1.1.1.1.2.2 jym next;
535 1.1.1.1.2.2 jym }
536 1.1.1.1.2.2 jym }
537 1.1.1.1.2.2 jym if( $verbose )
538 1.1.1.1.2.2 jym {
539 1.1.1.1.2.2 jym for (keys %rinfo)
540 1.1.1.1.2.2 jym {
541 1.1.1.1.2.2 jym verbose( "Revision $_: " );
542 1.1.1.1.2.2 jym verbose( join( ", ", %{$rinfo{$_}} ) );
543 1.1.1.1.2.2 jym verbose( "\n" );
544 1.1.1.1.2.2 jym }
545 1.1.1.1.2.2 jym }
546 1.1.1.1.2.2 jym
547 1.1.1.1.2.2 jym die "Syserr closing pipe from `cvs co': $!"
548 1.1.1.1.2.2 jym if !$fh->close && $!;
549 1.1.1.1.2.2 jym return if $?;
550 1.1.1.1.2.2 jym
551 1.1.1.1.2.2 jym return( \%finfo, %rinfo ? \%rinfo : undef );
552 1.1.1.1.2.2 jym }
553 1.1.1.1.2.2 jym
554 1.1.1.1.2.2 jym ######################################################################
555 1.1.1.1.2.2 jym #
556 1.1.1.1.2.2 jym # NAME :
557 1.1.1.1.2.2 jym # check_revision
558 1.1.1.1.2.2 jym #
559 1.1.1.1.2.2 jym # PURPOSE :
560 1.1.1.1.2.2 jym # Given a file and a revision number ensure that we can check out that
561 1.1.1.1.2.2 jym # file.
562 1.1.1.1.2.2 jym #
563 1.1.1.1.2.2 jym # If the user has specified any scripts (passed in as arguments to --exec
564 1.1.1.1.2.2 jym # and stored in @scripts), run them on the checked out revision. If
565 1.1.1.1.2.2 jym # executable scripts exit with a non-zero status or evaluated scripts set
566 1.1.1.1.2.2 jym # $@ (die), print $status or $@ as a warning.
567 1.1.1.1.2.2 jym #
568 1.1.1.1.2.2 jym # PARAMETERS :
569 1.1.1.1.2.2 jym # $file - The file to look at.
570 1.1.1.1.2.2 jym # $revision - The revision to look at.
571 1.1.1.1.2.2 jym # $rinfo - A reference to a hash containing information about the
572 1.1.1.1.2.2 jym # revisions in $file.
573 1.1.1.1.2.2 jym # For instance, $rinfo->{$revision}->{'date'} contains the
574 1.1.1.1.2.2 jym # date revision $revision was committed.
575 1.1.1.1.2.2 jym #
576 1.1.1.1.2.2 jym # GLOBALS :
577 1.1.1.1.2.2 jym # NONE
578 1.1.1.1.2.2 jym #
579 1.1.1.1.2.2 jym # RETURNS :
580 1.1.1.1.2.2 jym # If we can get the File - 1
581 1.1.1.1.2.2 jym # If we can not get the File - 0
582 1.1.1.1.2.2 jym #
583 1.1.1.1.2.2 jym # COMMENTS :
584 1.1.1.1.2.2 jym # cvs command line options are as followed:
585 1.1.1.1.2.2 jym # -n - Do not run any checkout program as specified by the -o
586 1.1.1.1.2.2 jym # option in the modules file
587 1.1.1.1.2.2 jym # -p - Put all output to standard out.
588 1.1.1.1.2.2 jym # -r - The revision of the file that we would like to look at.
589 1.1.1.1.2.2 jym # -ko - Get the revision exactly as checked in - do not allow
590 1.1.1.1.2.2 jym # RCS keyword substitution.
591 1.1.1.1.2.2 jym # Please note that cvs will return 0 for being able to successfully
592 1.1.1.1.2.2 jym # read the file and 1 for failure to read the file.
593 1.1.1.1.2.2 jym #
594 1.1.1.1.2.2 jym ######################################################################
595 1.1.1.1.2.2 jym sub check_revision
596 1.1.1.1.2.2 jym {
597 1.1.1.1.2.2 jym my( $file, $revision, $finfo, $rinfo ) = @_;
598 1.1.1.1.2.2 jym $file =~ s/(["\$`\\])/\\$1/g;
599 1.1.1.1.2.2 jym
600 1.1.1.1.2.2 jym # Allow binaries to be checked out as such. Otherwise, use -ko to avoid
601 1.1.1.1.2.2 jym # replacing keywords in the files.
602 1.1.1.1.2.2 jym my $kwmode = $finfo->{'kwmode'} eq 'b' ? '' : ' -ko';
603 1.1.1.1.2.2 jym my $command = "cvs -d $cvsroot co$kwmode -npr $revision \"$file\"";
604 1.1.1.1.2.2 jym my $ret_code;
605 1.1.1.1.2.2 jym verbose( "Executing `$command'.\n" );
606 1.1.1.1.2.2 jym if( @scripts )
607 1.1.1.1.2.2 jym {
608 1.1.1.1.2.2 jym my $fh = new IO::File $command . ($verbose ? "" : " 2>&1") . " |";
609 1.1.1.1.2.2 jym fcntl( $fh, F_SETFD, 0 )
610 1.1.1.1.2.2 jym or die "Can't clear close-on-exec flag on filehandle: $!";
611 1.1.1.1.2.2 jym my $count;
612 1.1.1.1.2.2 jym foreach my $script (@scripts)
613 1.1.1.1.2.2 jym {
614 1.1.1.1.2.2 jym $count++;
615 1.1.1.1.2.2 jym if( $script !~ /\n/ && -x $script )
616 1.1.1.1.2.2 jym {
617 1.1.1.1.2.2 jym # exec external script
618 1.1.1.1.2.2 jym my $status = system $script, $cvsroot, $file, $revision,
619 1.1.1.1.2.2 jym fileno( $fh );
620 1.1.1.1.2.2 jym warn "`$script $cvsroot $file $revision "
621 1.1.1.1.2.2 jym . fileno( $fh )
622 1.1.1.1.2.2 jym . "' exited with code $status"
623 1.1.1.1.2.2 jym if $status;
624 1.1.1.1.2.2 jym }
625 1.1.1.1.2.2 jym else
626 1.1.1.1.2.2 jym {
627 1.1.1.1.2.2 jym # eval script
628 1.1.1.1.2.2 jym @_ = ($cvsroot, $file, $revision, $fh);
629 1.1.1.1.2.2 jym eval $script;
630 1.1.1.1.2.2 jym warn "script $count ($cvsroot, $file, $revision, $fh) exited abnormally: $@"
631 1.1.1.1.2.2 jym if $@;
632 1.1.1.1.2.2 jym }
633 1.1.1.1.2.2 jym }
634 1.1.1.1.2.2 jym # Read any data left so the close will work even if our called script
635 1.1.1.1.2.2 jym # didn't finish reading the data.
636 1.1.1.1.2.2 jym () = $fh->getlines; # force list context
637 1.1.1.1.2.2 jym die "Syserr closing pipe from `cvs co': $!"
638 1.1.1.1.2.2 jym if !$fh->close && $!;
639 1.1.1.1.2.2 jym $ret_code = $?;
640 1.1.1.1.2.2 jym }
641 1.1.1.1.2.2 jym else
642 1.1.1.1.2.2 jym {
643 1.1.1.1.2.2 jym $ret_code = 0xffff & system "$command >/dev/null 2>&1";
644 1.1.1.1.2.2 jym }
645 1.1.1.1.2.2 jym
646 1.1.1.1.2.2 jym return !$ret_code;
647 1.1.1.1.2.2 jym }
648 1.1.1.1.2.2 jym
649 1.1.1.1.2.2 jym ######################################################################
650 1.1.1.1.2.2 jym #
651 1.1.1.1.2.2 jym # NAME :
652 1.1.1.1.2.2 jym # find_interesting_revisions
653 1.1.1.1.2.2 jym #
654 1.1.1.1.2.2 jym # PURPOSE :
655 1.1.1.1.2.2 jym # CVS stores information in a logical manner. We only really
656 1.1.1.1.2.2 jym # need to look at some interestin revisions. These are:
657 1.1.1.1.2.2 jym # The first version
658 1.1.1.1.2.2 jym # And the last version on every branch.
659 1.1.1.1.2.2 jym # This is because cvs stores changes descending from
660 1.1.1.1.2.2 jym # main line. ie suppose the last version on mainline is 1.6
661 1.1.1.1.2.2 jym # version 1.6 of the file is stored in toto. version 1.5
662 1.1.1.1.2.2 jym # is stored as a diff between 1.5 and 1.6. 1.4 is stored
663 1.1.1.1.2.2 jym # as a diff between 1.5 and 1.4.
664 1.1.1.1.2.2 jym # branches are stored a little differently. They are
665 1.1.1.1.2.2 jym # stored in ascending order. Suppose there is a branch
666 1.1.1.1.2.2 jym # on 1.4 of the file. The first branches revision number
667 1.1.1.1.2.2 jym # would be 1.4.1.1. This is stored as a diff between
668 1.1.1.1.2.2 jym # version 1.4 and 1.4.1.1. The 1.4.1.2 version is stored
669 1.1.1.1.2.2 jym # as a diff between 1.4.1.1 and 1.4.1.2. Therefore
670 1.1.1.1.2.2 jym # we are only interested in the earliest revision number
671 1.1.1.1.2.2 jym # and the highest revision number on a branch.
672 1.1.1.1.2.2 jym #
673 1.1.1.1.2.2 jym # PARAMETERS :
674 1.1.1.1.2.2 jym # @revisions - The list of revisions to find interesting ones
675 1.1.1.1.2.2 jym #
676 1.1.1.1.2.2 jym # GLOBALS :
677 1.1.1.1.2.2 jym # NONE
678 1.1.1.1.2.2 jym #
679 1.1.1.1.2.2 jym # RETURNS :
680 1.1.1.1.2.2 jym # @new_revisions - The list of revisions that we find interesting
681 1.1.1.1.2.2 jym #
682 1.1.1.1.2.2 jym # COMMENTS :
683 1.1.1.1.2.2 jym #
684 1.1.1.1.2.2 jym ######################################################################
685 1.1.1.1.2.2 jym sub find_interesting_revisions
686 1.1.1.1.2.2 jym {
687 1.1.1.1.2.2 jym my( @revisions ) = @_;
688 1.1.1.1.2.2 jym my @new_revisions;
689 1.1.1.1.2.2 jym my %max_branch_revision;
690 1.1.1.1.2.2 jym my $branch_number;
691 1.1.1.1.2.2 jym my $branch_rev;
692 1.1.1.1.2.2 jym my $key;
693 1.1.1.1.2.2 jym my $value;
694 1.1.1.1.2.2 jym
695 1.1.1.1.2.2 jym foreach my $revision( @revisions )
696 1.1.1.1.2.2 jym {
697 1.1.1.1.2.2 jym ( $branch_number, $branch_rev ) = branch_split( $revision );
698 1.1.1.1.2.2 jym $max_branch_revision{$branch_number} = $branch_rev
699 1.1.1.1.2.2 jym if( !exists $max_branch_revision{$branch_number}
700 1.1.1.1.2.2 jym || $max_branch_revision{$branch_number} < $branch_rev );
701 1.1.1.1.2.2 jym }
702 1.1.1.1.2.2 jym
703 1.1.1.1.2.2 jym push( @new_revisions, "1.1" ) unless (exists $max_branch_revision{1}
704 1.1.1.1.2.2 jym && $max_branch_revision{1} == 1);
705 1.1.1.1.2.2 jym while( ( $key, $value ) = each ( %max_branch_revision ) )
706 1.1.1.1.2.2 jym {
707 1.1.1.1.2.2 jym push( @new_revisions, $key . "." . $value );
708 1.1.1.1.2.2 jym }
709 1.1.1.1.2.2 jym
710 1.1.1.1.2.2 jym my $nrc;
711 1.1.1.1.2.2 jym my $rc;
712 1.1.1.1.2.2 jym
713 1.1.1.1.2.2 jym $rc = @revisions;
714 1.1.1.1.2.2 jym $nrc = @new_revisions;
715 1.1.1.1.2.2 jym
716 1.1.1.1.2.2 jym $total_revisions += $rc;
717 1.1.1.1.2.2 jym $total_interesting_revisions += $nrc;
718 1.1.1.1.2.2 jym
719 1.1.1.1.2.2 jym verbose( "\t\tTotal Revisions: $rc Interesting Revisions: $nrc\n" );
720 1.1.1.1.2.2 jym
721 1.1.1.1.2.2 jym return( @new_revisions );
722 1.1.1.1.2.2 jym }
723 1.1.1.1.2.2 jym
724 1.1.1.1.2.2 jym
725 1.1.1.1.2.2 jym
726 1.1.1.1.2.2 jym ######################################################################
727 1.1.1.1.2.2 jym #
728 1.1.1.1.2.2 jym # NAME :
729 1.1.1.1.2.2 jym # branch_split
730 1.1.1.1.2.2 jym #
731 1.1.1.1.2.2 jym # PURPOSE :
732 1.1.1.1.2.2 jym # To split up a revision number up into the branch part and
733 1.1.1.1.2.2 jym # the number part. For Instance:
734 1.1.1.1.2.2 jym # 1.1.1.1 - is split 1.1.1 and 1
735 1.1.1.1.2.2 jym # 2.1 - is split 2 and 1
736 1.1.1.1.2.2 jym # 1.3.4.5.7.8 - is split 1.3.4.5.7 and 8
737 1.1.1.1.2.2 jym #
738 1.1.1.1.2.2 jym # PARAMETERS :
739 1.1.1.1.2.2 jym # $revision - The revision to look at.
740 1.1.1.1.2.2 jym #
741 1.1.1.1.2.2 jym # GLOBALS :
742 1.1.1.1.2.2 jym # NONE
743 1.1.1.1.2.2 jym #
744 1.1.1.1.2.2 jym # RETURNS :
745 1.1.1.1.2.2 jym # ( $branch, $revision ) -
746 1.1.1.1.2.2 jym # $branch - The branch part of the revision number
747 1.1.1.1.2.2 jym # $revision - The revision part of the revision number
748 1.1.1.1.2.2 jym #
749 1.1.1.1.2.2 jym # COMMENTS :
750 1.1.1.1.2.2 jym # NONE
751 1.1.1.1.2.2 jym #
752 1.1.1.1.2.2 jym ######################################################################
753 1.1.1.1.2.2 jym sub branch_split
754 1.1.1.1.2.2 jym {
755 1.1.1.1.2.2 jym my( $revision ) = @_;
756 1.1.1.1.2.2 jym my $branch;
757 1.1.1.1.2.2 jym my $version;
758 1.1.1.1.2.2 jym my @split_rev;
759 1.1.1.1.2.2 jym my $count;
760 1.1.1.1.2.2 jym
761 1.1.1.1.2.2 jym @split_rev = split /\./, $revision;
762 1.1.1.1.2.2 jym
763 1.1.1.1.2.2 jym my $numbers = @split_rev;
764 1.1.1.1.2.2 jym @split_rev = reverse( @split_rev );
765 1.1.1.1.2.2 jym $branch = pop( @split_rev );
766 1.1.1.1.2.2 jym for( $count = 0; $count < $numbers - 2 ; $count++ )
767 1.1.1.1.2.2 jym {
768 1.1.1.1.2.2 jym $branch .= "." . pop( @split_rev );
769 1.1.1.1.2.2 jym }
770 1.1.1.1.2.2 jym
771 1.1.1.1.2.2 jym return( $branch, pop( @split_rev ) );
772 1.1.1.1.2.2 jym }
773 1.1.1.1.2.2 jym
774 1.1.1.1.2.2 jym ######################################################################
775 1.1.1.1.2.2 jym #
776 1.1.1.1.2.2 jym # NAME :
777 1.1.1.1.2.2 jym # get_ignore_files_from_cvsroot
778 1.1.1.1.2.2 jym #
779 1.1.1.1.2.2 jym # PURPOSE :
780 1.1.1.1.2.2 jym # Retrieve the list of files from the CVSROOT/ directory
781 1.1.1.1.2.2 jym # that should be ignored.
782 1.1.1.1.2.2 jym # These are the regular files (e.g., commitinfo, loginfo)
783 1.1.1.1.2.2 jym # and those specified in the checkoutlist file.
784 1.1.1.1.2.2 jym #
785 1.1.1.1.2.2 jym # PARAMETERS :
786 1.1.1.1.2.2 jym # The CVSROOT
787 1.1.1.1.2.2 jym #
788 1.1.1.1.2.2 jym # GLOBALS :
789 1.1.1.1.2.2 jym # NONE
790 1.1.1.1.2.2 jym #
791 1.1.1.1.2.2 jym # RETURNS :
792 1.1.1.1.2.2 jym # @ignore - the list of files to ignore
793 1.1.1.1.2.2 jym #
794 1.1.1.1.2.2 jym # COMMENTS :
795 1.1.1.1.2.2 jym # NONE
796 1.1.1.1.2.2 jym #
797 1.1.1.1.2.2 jym ######################################################################
798 1.1.1.1.2.2 jym sub get_ignore_files_from_cvsroot {
799 1.1.1.1.2.2 jym my( $cvsroot ) = @_;
800 1.1.1.1.2.2 jym my @ignore = (
801 1.1.1.1.2.2 jym qr{CVS/fileattr$}o,
802 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/.#[^/]*$}o,
803 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/checkoutlist$}o,
804 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/commitinfo$}o,
805 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/config$}o,
806 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/cvsignore$}o,
807 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/cvswrappers$}o,
808 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/editinfo$}o,
809 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/history$}o,
810 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/loginfo$}o,
811 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/modules$}o,
812 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/notify$}o,
813 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/passwd$}o,
814 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/postadmin$}o,
815 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/postproxy$}o,
816 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/posttag$}o,
817 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/postwatch$}o,
818 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/preproxy$}o,
819 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/rcsinfo$}o,
820 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/readers$}o,
821 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/taginfo$}o,
822 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/val-tags$}o,
823 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/verifymsg$}o,
824 1.1.1.1.2.2 jym qr{^(./)?CVSROOT/writers$}o
825 1.1.1.1.2.2 jym );
826 1.1.1.1.2.2 jym
827 1.1.1.1.2.2 jym my $checkoutlist_file = "$cvsroot/CVSROOT/checkoutlist";
828 1.1.1.1.2.2 jym if( -f $checkoutlist_file && -r $checkoutlist_file )
829 1.1.1.1.2.2 jym {
830 1.1.1.1.2.2 jym my $fh = new IO::File "<$checkoutlist_file"
831 1.1.1.1.2.2 jym or die "Unable to read checkoutlist file ($checkoutlist_file): $!\n";
832 1.1.1.1.2.2 jym
833 1.1.1.1.2.2 jym my @list = $fh->getlines;
834 1.1.1.1.2.2 jym chomp( @list );
835 1.1.1.1.2.2 jym $fh->close or die( "Unable to close checkoutlist file: $!\n" );
836 1.1.1.1.2.2 jym
837 1.1.1.1.2.2 jym foreach my $line( @list )
838 1.1.1.1.2.2 jym {
839 1.1.1.1.2.2 jym next if( $line =~ /^#/ || $line =~ /^\s*$/ );
840 1.1.1.1.2.2 jym $line =~ s/^\s*(\S+)(\s+.*)?$/$1/;
841 1.1.1.1.2.2 jym push @ignore, qr{^(./)?CVSROOT/$line$};
842 1.1.1.1.2.2 jym }
843 1.1.1.1.2.2 jym }
844 1.1.1.1.2.2 jym
845 1.1.1.1.2.2 jym return @ignore;
846 1.1.1.1.2.2 jym }
847 1.1.1.1.2.2 jym
848 1.1.1.1.2.2 jym
849 1.1.1.1.2.2 jym
850 1.1.1.1.2.2 jym ######
851 1.1.1.1.2.2 jym ###### Go.
852 1.1.1.1.2.2 jym ######
853 1.1.1.1.2.2 jym
854 1.1.1.1.2.2 jym exit main @ARGV;
855 1.1.1.1.2.2 jym
856 1.1.1.1.2.2 jym # vim:tabstop=4:shiftwidth=4
857