[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Limit size of emails sent using commit-email.pl

From: <kfogel_at_collab.net>
Date: 2005-01-19 21:49:27 CET

VK Sameer <sameer@collab.net> writes:
> OK, removed the max diff size variable. I just wasn't sure if there
> could be a situation where non-diff content could be large as well.
>
> Regards
> Sameer
> Add variable to control email message size based on email body size
>
> * commit-email.pl.in
> $max_email_body_size: New variable
> check_truncate(): New function to truncate an array of strings
> Added call to check (and possibly truncate) size of @body

Did you consider a solution in which instead of truncating a large
diff, we just replace it with the appropriate ViewCVS diff URL?

I think showing half a diff is not very useful. Better to simply not
show it at all, and instead give a pointer to get the diff online.

-Karl

> 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]);
> + }
> +}
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Jan 19 21:58:45 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.