Index: tools/hook-scripts/commit-email.pl.in =================================================================== --- tools/hook-scripts/commit-email.pl.in (revision 12754) +++ tools/hook-scripts/commit-email.pl.in (working copy) @@ -57,6 +57,9 @@ # $no_diff_added to 1. my $no_diff_added = 0; +# This controls the size of the commit email. +my $max_email_body_size = 1_000_000; # characters + # Since the path to svnlook depends upon the local installation # preferences, check that the required programs exist to insure that # the administrator has set up the script properly. @@ -368,6 +371,7 @@ push(@body, @log); push(@body, "\n"); push(@body, map { /[\r\n]+$/ ? $_ : "$_\n" } @difflines); +&check_truncate (\@body, $max_email_body_size); # Go through each project and see if there are any matches for this # project. If so, send the log out. @@ -598,3 +602,22 @@ return @output; } } + +# This truncates @{$r_array} if the cumulative length of strings in +# @{$r_array} exceeds $max_size. The array is truncated at the line +# whose string length would cause this to happen. +sub check_truncate +{ + my ($r_array, $max_size) = @_; + + for (my ($line, $size) = (0, 0); $line <= $#{$r_array}; $line++) + { + if (($size + length $r_array->[$line]) > $max_size) + { + splice(@{$r_array}, $line, 0, + "[truncated - reached $max_size ...]\n"); + last; + } + $size += length($r_array->[$line]); + } +}