#!/usr/bin/perl -i.bak -p # (C) 2004-2005, Mark A. Hillebrand # Purpose: does something similar to cvs2cl --accum # Usage: Provide the ChangeLog name as first (single) argument # First time usage: create initial ChangeLog via `svn log > ChangeLog' # or `svn log --verbose > ChangeLog' # # TODO under certain circumstance, line 1 contains `No commit for revision 0.' # - maybe handle this if( $.==1 ) { $first=$_; # save first line (of hyphens) for possible later use $_=''; # don't print } elsif( $.==2 ) { unless( m/^r(\d+)/ ) { rename "$ARGV.bak", $ARGV if defined $ARGV; die "?Parse error in line $.; stopping.\n"; }; $second=$_; # save line for later use $revision=$1; # save revision for later use $_=''; # don't print } elsif( $.==3 ) { # Detect whether the ChangeLog was created with verbosity option $verbose = m/^Changed paths:$/ ? '--verbose' : ''; # put $first line back in, if there was no new revision, otherwise, # the line of hyphens comes from the log command warn "svn log $verbose -r HEAD:@{[$revision+1]} 2>/dev/null\n"; print `svn log $verbose -r HEAD:@{[$revision+1]} 2>/dev/null` || $first; $_ = $second.$_; # always second and current (i.e., old third) line afterwards }