: #-*- Perl -*- eval 'exec perl -w -S $0 ${1+"$@"}' # Portability kludge if 0; ### cvs-mods --- list all modified files in a CVS tree, w/o server access ## Copyright (C) 2001 Ben Wing. ## Author: Ben Wing , Martin Buchholz ## Original Author: Martin Buchholz ## Maintainer: Ben Wing ## Current Version: 1.1, April 6, 2001 ## This file is part of XEmacs. ## XEmacs 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, or (at your option) ## any later version. ## XEmacs 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 XEmacs; see the file COPYING. If not, write to the Free ## Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. use strict; use File::stat; (my $myName = $0) =~ s@.*/@@; my $usage=" Usage: $myName [-v] [--help] [dir|file ...] Finds and outputs all modified CVS files specified on the command line or within directory trees specified on the command line. This does not contact the CVS server, so it is very fast, and is useful to speed up other CVS-based scripts. "; my $verbose = 0; while (@ARGV && ($_ = $ARGV[0], /^-/)) { shift; last if /^--$/; if (/^-v$/) { $verbose = 1; } if (/^--help$/) { die $usage; } } sub ParsePath { my $pos = rindex ($_[0], "/"); return ($pos > 0 ? (substr ($_[0], 0, $pos), substr ($_[0], $pos+1)) : $pos == -1 ? ('.', $_[0]) : ("/", substr ($_[0], 1))); } sub CheckModified { return unless $_[0] =~ m:^/:; my ($name, $revision, $timestamp) = (split('/', $_[0]))[1,2,3]; my $file = "$_[1]/$name"; $file =~ s:^\./::; if (! -e $file) { print "Removed: " if $verbose; print "$file\n"; } else { my $file_timestamp = scalar gmtime (stat($file)->mtime); return if $timestamp eq $file_timestamp; # Unchanged print "Modified: " if $verbose; print "$file\n"; } } @ARGV = ('.') if (! @ARGV); while (my $arg = shift @ARGV) { if (-d $arg) { die "Not a CVS directory tree.\n" unless -d "$arg/CVS"; open(FIND, "find $arg -type d -print |") or die "$!"; while () { chomp (my $dir = $_); my $entries = "$dir/CVS/Entries"; next unless -r "$entries"; open (ENTRIES, "$entries") or die "$!"; while () { &CheckModified ($_, $dir); } close (ENTRIES); } close (FIND); } else { my ($dir, $file) = &ParsePath ($arg); my $entries = "$dir/CVS/Entries"; next unless -r "$entries"; open (ENTRIES, "$entries") or die "$!"; while () { &CheckModified ($_, $dir) if m:^/$file/:; } close (ENTRIES); } }