X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=clients%2FLynuxWorks%2Fbin%2Ffiles4ecr;fp=clients%2FLynuxWorks%2Fbin%2Ffiles4ecr;h=31c381a5d5753df70177ea1e292f3bdfd2388503;hb=a8c84d2892f07a6863b68a11eb0a4a79ffd71fb5;hp=0000000000000000000000000000000000000000;hpb=95384f94f88aceeb5eef2d322210ba4a438b6512;p=clearscm.git diff --git a/clients/LynuxWorks/bin/files4ecr b/clients/LynuxWorks/bin/files4ecr new file mode 100644 index 0000000..31c381a --- /dev/null +++ b/clients/LynuxWorks/bin/files4ecr @@ -0,0 +1,185 @@ +#!/usr/bin/perl +################################################################################ +# +# File: files4ecr +# Description: This script will go through CVS looking for files that have +# the passed in ECR #. +# Author: Andrew@DeFaria.com +# Created: Fri Dec 17 12:18:21 PST 2004 +# Language: Perl +# +# (c) Copyright 2004, LynxWorks Inc., all rights reserved +# +################################################################################ +use warnings; +use strict; + +# Options +my $verbose = 0; +my $debug = 0; +my $execute = 0; +my $local = ""; + +my $ecr; + +sub verbose { + my $msg = shift; + + print "$msg\n" if $verbose; +} # verbose + +sub debug { + my $msg = shift; + + print "DEBUG: $msg\n" if $debug; +} # debug + +sub Usage { + my $msg = shift; + + print "ERROR: $msg\n\n" if defined $msg; + + print "Usage: files4ecr [-v] [-d] [-l] [-x] [-u] \n"; + print "\nWhere:\n\n"; + print "\t-v:\t\tTurn on verbose mode (Default: off)\n"; + print "\t-d:\t\tTurn on debug mode (Default: off)\n"; + print "\t-l:\t\tLocal directory only, no recursion\n"; + print "\t-x:\t\tTurn on execute mode (Default: off)\n"; + print "\t-u:\t\tDisplay usage\n"; + print "\tecr\t\tECR number to search for\n"; + exit 1; +} # Usage + +sub GetFiles4 { + my $ecr = shift; + my $local = shift; + + # Perform a cvs log command and grep through the output + print "Gathering CVS info..." if $verbose; + my @output = grep { + /^Working file: / or + /^revision / or + /^\s*ECR#/ or + /^\s*ECR / + } `cvs -q log $local 2>/dev/null`; + verbose " done"; + + # Now process this array. Entries may look like: + # + # Working file: + # revision + # revision + # ECR Number: + # + # It's quite possible that there are no ECR numbers for a file. It's also + # possible that there is the same ECR number for multiple revisions! For + # example: + # + # Working file: + # revision 10.2 + # ECR Number: 1000 + # revision 10.1 + # ECR Number: 1000 + # + # In this case we want to return the and 10.2. + + my %files; + my $filename; + my $revision; + + while ($_ = shift @output) { + chomp; + chop if /\r/; + + if (/^Working file: (.*)/) { + $filename = $1; + debug "file: $filename"; + } elsif (/^revision (.*)/) { + $revision = $1; + debug "revision: $revision"; + } elsif (/^ECR Number: (\d*)$/ or + /^ECR# (\d*)$/ or + /^ECR # (\d*)$/ or + /^\s*ECR (\d*)/) { + debug "ECR: $1"; + if ($ecr eq $1) { + $files{$filename} = $revision; + debug "Set $filename: $revision"; + + # Now skip to next file + do { + $_ = shift @output; + } while @output and !/Working file: /; + unshift @output, $_; + } # if + } else { + verbose "Unknown line encountered: $_\n"; + } # if + } # foreach + + return %files; +} # GetFiles4 + +sub GetWorkingRev { + my $filename = shift; + + my @output = grep { /Working revision:/ } `cvs status $filename`; + + if (defined $output [0] and $output [0] =~ /Working revision:\s*(\S*)/) { + return $1; + } # if + + return undef; +} # GetWorkingRev + +# Get args +while ($ARGV [0]) { + if ($ARGV [0] eq "-d") { + $debug = 1; + } elsif ($ARGV [0] eq "-v") { + $verbose = 1; + } elsif ($ARGV [0] eq "-l") { + $local = $ARGV [0]; + } elsif ($ARGV [0] eq "-x") { + $execute = 1; + } elsif ($ARGV [0] eq "-u") { + Usage; + } # if + + $ecr = $ARGV [0]; + + shift (@ARGV); +} # while + +Usage "No ECR specified to process" if !defined $ecr; + +my %files = GetFiles4 $ecr, $local; + +foreach (keys %files) { + my $working_revision = GetWorkingRev $_; + my $up_to_date = 0; + + if (defined $working_revision and $working_revision eq $files{$_}) { + $up_to_date = 1; + } # if + + if ($execute) { + print "cvs update -r$files{$_} $_"; + + if (!$up_to_date) { + `cvs update -r$files{$_} $_`; + print " - Updated\n"; + } else { + print " - Already up to date\n"; + } # if + } else { + print "$_: $files{$_}"; + + if ($up_to_date) { + print " - Already up to date\n"; + } else { + print " - Out of date\n"; + } # if + } # if +} # foreach +