#!/usr/bin/perl use strict; # 0.4 - Improved CVS directory parsing makes better output # 'use strict' makes it less error prone # 0.5 - Added support for "Unresolved Conflict" and "Entry Invalid" # 0.6 - Rewrote it to do individual 'cvs status' invokes in every # directory that seems to be under CVS control. It makes it # easier to track directory name etc # 0.7 - Improved it more, works smoother with CVS servers my $allfiles; my $mychanges; my $verbose; my $summary; my $cdpath ="."; my $localonly=0; my $debug; do { if($ARGV[0] eq "-a") { $allfiles=1; } elsif($ARGV[0] eq "-d") { $debug=1; } elsif($ARGV[0] eq "-c") { $mychanges=1; } elsif($ARGV[0] eq "-v") { $verbose=1; } elsif($ARGV[0] eq "-l") { $localonly=1; } elsif($ARGV[0] eq "-s") { $summary="-s"; } elsif($ARGV[0] eq "-h") { print "cvscheck 0.7 (Daniel Stenberg )\n", "Usage: cvscheck [-achlv] [path]\n", " -a Show all files\n", " -c Only display locally modified files\n", " -d Run this script in debug-mode\n", " -h This help text\n", " -l Local directory only, don't do this recursively\n", " -v Verbose, include more details\n"; exit; } else { if($ARGV[0] ne "") { $cdpath=$ARGV[0]; } } } while(shift); my $pwd=`pwd`; chomp $pwd; if(!$localonly) { open(ALLDIRS, "find $cdpath -name CVS|"); } else { open(ALLDIRS, "echo ./CVS|"); } while() { my $dir = $_; chomp $dir; if($dir !~ s/\/CVS$//) { # it didn't end with CVS, skip to next dir please next; } # we cut off the CVS part, do status on the given directory if($debug) { print "CHECK and chdir to $dir\n"; } chdir($dir); # cd to the target dir open(CHECK, "cvs status -l 2>/dev/null|"); my $name; # file name my %file; # hash table for info my @files; # array for file names my $status; my ($workver, $workdate, $repver, $repfile); while() { chomp; if($debug) { print "STATUS: $_\n"; } if($_ =~ /^=============================/) { undef $name; # this is the beginning of a new file } elsif($_ =~ /^File: (.*)[ \t]+Status: *(.*)/) { $name=$1; $status=$2; $name =~ s/([ \t]*)$//; # print "NAME: \"$name\" STAT: $status\n"; push @files, $name; } elsif($_ =~ /^ Working revision:[ \t]*([^ \t]+)[ \t]*(.*)/) { $workver=$1; $workdate=$2; } elsif($_ =~ /^ Repository revision:[ \t]*([^ \t]+)[ \t]*(.*)/) { $repver=$1; $repfile=$2; my $realfile="$dir/$name"; #$repver="not present"; $repfile="$name"; my $show=0; if($status eq "Entry Invalid") { $show=0; } elsif($allfiles) { $show=1; } elsif (($status ne "Up-to-date") && !$mychanges) { $show=1; } elsif($mychanges && ($status eq "Locally Modified") ) { $show=1; } if($show) { print "$realfile => $status\n"; if($verbose) { print " Work version: $workver $workdate\n", " CVS version: $repver\n"; } } } else { # print "MISS $_\n"; } } if($debug) { print "CHDIR to $pwd\n"; } chdir($pwd); # cd back to "root" }