Index: tools/hook-scripts/commit-email.pl.in =================================================================== --- tools/hook-scripts/commit-email.pl.in (revision 12679) +++ tools/hook-scripts/commit-email.pl.in (working copy) @@ -57,6 +57,14 @@ # $no_diff_added to 1. my $no_diff_added = 0; +# This set of variables controls the size of the commit email. By +# default, when a file is added or deleted, svnlook diff prints the +# entire contents of the file. max_diff_size is used to truncate the +# diff information if necessary. max_email_body_size further truncates +# the email body. +my $max_diff_size = 900_000; # characters +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. @@ -286,6 +294,7 @@ my @difflines = &read_from_process($svnlook, 'diff', $repos, '-r', $rev, @no_diff_deleted, @no_diff_added); +&check_truncate (\@difflines, $max_diff_size); ###################################################################### # Modified directory name collapsing. @@ -368,6 +377,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 +608,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]); + } +}