diff options
author | joe <joe@FreeBSD.org> | 2001-04-20 00:43:57 +0800 |
---|---|---|
committer | joe <joe@FreeBSD.org> | 2001-04-20 00:43:57 +0800 |
commit | 91a7186a7b96319cb6121c80bc32c0bff287da5d (patch) | |
tree | d03f585594d969efdd0aa472a51a59934d2ad586 | |
parent | 348f2d4502b8bb5b9d1b92e1fe79da4861fc7839 (diff) | |
download | freebsd-ports-gnome-91a7186a7b96319cb6121c80bc32c0bff287da5d.tar.gz freebsd-ports-gnome-91a7186a7b96319cb6121c80bc32c0bff287da5d.tar.zst freebsd-ports-gnome-91a7186a7b96319cb6121c80bc32c0bff287da5d.zip |
Clean up the CVS log message parser and in the process fix a
potential bug where the contents of the log message could conflict
with the parsing process.
-rwxr-xr-x | CVSROOT/log_accum.pl | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/CVSROOT/log_accum.pl b/CVSROOT/log_accum.pl index 68c016b01836..ef227dc3f5f5 100755 --- a/CVSROOT/log_accum.pl +++ b/CVSROOT/log_accum.pl @@ -516,8 +516,6 @@ umask (002); # Initialize basic variables # $PID = getpgrp(); -$state = $STATE_NONE; -$tag = ''; $login = $ENV{'USER'} || getlogin || (getpwuid($<))[0] || sprintf("uid#%d",$<); @files = split(' ', $ARGV[0]); @path = split('/', $files[0]); @@ -577,41 +575,53 @@ if ($ARGV[0] =~ /Imported sources/) { # # Iterate over the body of the message collecting information. # -$tag = "HEAD"; +my %added_files; # Hashes containing lists of files +my %changed_files; # that have been changed, keyed +my %removed_files; # by branch tag. + +my @log_lines; # The lines of the log message. + +my $tag = "HEAD"; # Default branch is HEAD. +my $state = $STATE_NONE; # Initially in no state. + while (<STDIN>) { s/[ \t\n]+$//; # delete trailing space - if (/^Revision\/Branch:/) { - s,^Revision/Branch:,,; - $tag = $_; - next; - } - if (/^[ \t]+Tag:/) { - s,^[ \t]+Tag: ,,; - $tag = $_; - next; - } - if (/^[ \t]+No tag$/) { - $tag = "HEAD"; - next; + + # parse the revision tag if it exists. + if (/^Revision\/Branch:(.*)/) { $tag = $1; next; } + if (/^[ \t]+Tag: (.*)/) { $tag = $1; next; } + if (/^[ \t]+No tag$/) { $tag = "HEAD"; next; } + + # check for a state change, guarding against similar markers + # in the log message itself. + unless ($state == $STATE_LOG) { + if (/^Modified Files/) { $state = $STATE_CHANGED; next; } + if (/^Added Files/) { $state = $STATE_ADDED; next; } + if (/^Removed Files/) { $state = $STATE_REMOVED; next; } + if (/^Log Message/) { $state = $STATE_LOG; next; } } - if (/^Modified Files/) { $state = $STATE_CHANGED; next; } - if (/^Added Files/) { $state = $STATE_ADDED; next; } - if (/^Removed Files/) { $state = $STATE_REMOVED; next; } - if (/^Log Message/) { $state = $STATE_LOG; next; } - - push (@{ $changed_files{$tag} }, split) if ($state == $STATE_CHANGED); - push (@{ $added_files{$tag} }, split) if ($state == $STATE_ADDED); - push (@{ $removed_files{$tag} }, split) if ($state == $STATE_REMOVED); + + # don't so anything if we're not in a state. + next if $state == $STATE_NONE; + + # collect the log line (ignoring empty template entries)? if ($state == $STATE_LOG) { - if (/^PR:$/i || + unless ( + /^PR:$/i || /^Reviewed by:$/i || /^Submitted by:$/i || /^Obtained from:$/i || /^Approved by:$/i) { - next; + push @log_lines, $_; } - push (@log_lines, $_); + next; } + + # otherwise collect information about which files changed. + my @files = split; + push @{ $changed_files{$tag} }, @files if $state == $STATE_CHANGED; + push @{ $added_files{$tag} }, @files if $state == $STATE_ADDED; + push @{ $removed_files{$tag} }, @files if $state == $STATE_REMOVED; } &append_line("$TAGS_FILE.$PID", $tag); |