#!/usr/bin/perl ##------------------------------------------------------------------------## ## File: ## $Id: cvs-info,v 1.3 2002/10/31 06:24:16 ehood Exp $ ## Author: ## Earl Hood earl@earlhood.com ## Description: ## Program to check status of CVS working tree. ## POD at end of script. ##------------------------------------------------------------------------## ## Copyright (C) 2001-2002 Earl Hood, earl@earlhood.com ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA ##------------------------------------------------------------------------## package Devtools::cvs_info; use FindBin; use lib "$FindBin::Bin/../lib"; # Add relative lib to search path MAIN: { local(*CVS); $child_pid = open(CVS, "-|"); if (!$child_pid) { # child open(STDERR, '>&STDOUT'); exec('cvs', 'status', @ARGV) || die qq/ERROR: Cannot exec cvs: $!\n/; } # parent local $_; my $path = ""; my $list = [ '' ]; my @files = ( $list ); my($file, $status); while () { chomp; if (/Examining (.+)$/) { $path = $1; $list = [ $path ]; push( @files, $list ); next; } if (/\[status/ || (/waiting/ && /lock/)) { print $_, "\n"; next; } next unless /Status: (Locally.*)$/ || /Status: (Needs.*)$/ || /Status: (Unknown.*)$/; $status = $1; ($file) = $_ =~ /File: (.*)Status: /; $file =~ s/\s+$//; # remove trailing whitespace $file =~ s/no file //; # remove "no file " from removed files push(@$list, [ $file, $status ]); } close(CVS); my($pad); foreach my $list (@files) { next unless scalar(@$list) > 1; $path = shift @$list; if ($path eq "") { $pad = ""; } else { print "$path/\n"; $pad = " "; } foreach my $item (@$list) { print sprintf("%s%-50s %s\n", $pad, $item->[0], $item->[1]); } } } __END__ =head1 NAME cvs-info - Provide summary of modified files in CVS working tree =head1 SYNOPSIS cvs-info [options] [pathname] ... =head1 DESCRIPTION This program provides a summary listing of files within a CVS working tree that have modified, added, removed, or need of updating. This program invokes the C command internally and parses the output of it to provide the summary listing. =head1 OPTIONS All options that are valid for C are allowed. =head1 ENVIRONMENT All environment variables applicable for C. =head1 LIMITATIONS =over =item * CVS general options cannot be passed into this script; i.e. options that are normally allowed between C and the specified cvs command. =back =head1 AUTHOR Earl Hood, C =cut