2 ################################################################################
5 # Description: This script will go through CVS looking for files that have
7 # Author: Andrew@DeFaria.com
8 # Created: Fri Dec 17 12:18:21 PST 2004
11 # (c) Copyright 2004, LynxWorks Inc., all rights reserved
13 ################################################################################
28 print "$msg\n" if $verbose;
34 print "DEBUG: $msg\n" if $debug;
40 print "ERROR: $msg\n\n" if defined $msg;
42 print "Usage: files4cr [-v] [-d] [-l] [-x] [-u] <cr>\n";
44 print "\t-v:\t\tTurn on verbose mode (Default: off)\n";
45 print "\t-d:\t\tTurn on debug mode (Default: off)\n";
46 print "\t-l:\t\tLocal directory only, no recursion\n";
47 print "\t-x:\t\tTurn on execute mode (Default: off)\n";
48 print "\t-u:\t\tDisplay usage\n";
49 print "\tcr\t\tCR number to search for\n";
57 # Perform a cvs log command and grep through the output
58 print "Gathering CVS info..." if $verbose;
65 } `cvs -q log $local 2>/dev/null`;
68 # Now process this array. Entries may look like:
70 # Working file: <filename>
77 # It's quite possible that there are no CR numbers for a file. It's also
78 # possible that there is the same CR number for multiple revisions! For
81 # Working file: <filename>
89 # In this case we want to return the <filename> and 10.2.
95 while ($_ = shift @output) {
99 if (/^Working file: (.*)/) {
101 debug "file: $filename";
102 } elsif (/^revision (.*)/) {
104 debug "revision: $revision";
105 } elsif (/^date:.*state: (.*);.*/) {
106 # Check to see if dead!
108 # Indicate we're dead by setting $revision to blank.
109 debug "Dead file encountered $filename";
112 } elsif (/^CR Number: (\d*)$/ or
118 $files{$filename} = $revision;
119 debug "Set $filename: $revision";
121 # Now skip to next file
124 } while @output and !/^Working file: /;
128 verbose "Unknown line encountered: $_\n";
136 my $filename = shift;
138 my @output = grep { /Working revision:/ } `cvs status $filename`;
140 if (defined $output [0] and $output [0] =~ /Working revision:\s*(\S*)/) {
149 if ($ARGV [0] eq "-d") {
151 } elsif ($ARGV [0] eq "-v") {
153 } elsif ($ARGV [0] eq "-l") {
155 } elsif ($ARGV [0] eq "-x") {
157 } elsif ($ARGV [0] eq "-u") {
166 Usage "No CR specified to process" if !defined $cr;
168 my %files = GetFiles4 $cr, $local;
170 foreach (keys %files) {
171 if ($files{$_} eq "") {
172 print "$_: Is dead\n";
176 my $working_revision = GetWorkingRev $_;
179 if (defined $working_revision and $working_revision eq $files{$_}) {
184 print "cvs update -r$files{$_} $_";
187 `cvs update -r$files{$_} $_`;
188 print " - Updated\n";
190 print " - Already up to date\n";
193 print "$_: $files{$_}";
196 print " - Already up to date\n";
198 print " - Out of date\n";