: #-*- Perl -*- eval 'exec perl -w -S $0 ${1+"$@"}' # Portability kludge if 0; ### cvs-fix-chlogs --- Automatically resolve conflicts in ChangeLogs ## Copyright (C) 2001 Ben Wing. ## Author: Ben Wing ## Based on: Earlier version by Martin Buchholz ## Maintainer: Ben Wing ## Current Version: 1.0, 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 Automatically resolves conflicts in ChangeLogs. Meant to be executed just after cvs update."; die $usage if grep (/^-h/, @ARGV); my $debug = defined $ENV{VERBOSE} || defined $ENV{DEBUG}; die "Not a CVS directory tree.\n" unless -d "CVS"; chomp (my @files = `find . -name ChangeLog -print`); for my $file (@files) { my $contents = &FileContents ($file); if ($contents =~ s/^<{7} \S+\n((?:.*\n)*?)={7}\n((?:.*\n)*?)>{7} \S+\n/$1$2/mg) { print "Automatically resolving conflict in $file\n"; open (FILE, "> $file") or die "$file: $!\n"; print FILE $contents or die "$file: $!\n"; close FILE or die "$file: $!\n"; } else { print "No conflicts in $file\n"; } } sub ParsePath { my $pos = rindex ($_[0], "/"); return ($pos > 0 ? (substr ($_[0], 0, $pos), substr ($_[0], $pos+1)) : $pos == -1 ? ('.', $_[0]) : ("/", substr ($_[0], 1))); } sub FileContents { local $/ = undef; open (FILE, "< $_[0]") or die "$_[0]: $!"; my $retval = scalar ; # must hack away CRLF junk. $retval =~ s/\r\n/\n/g; return $retval; }