[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 v2

From: <kfogel_at_collab.net>
Date: 2005-01-23 20:49:58 CET

VK Sameer <sameer@collab.net> writes:
> A new log message and modified commit-email.pl.in are attached.
> Changing the truncate function to zero out the difflines became too
> difflines array specific, so it has been called process_diff instead.

Thanks, Sameer! I've printed this out, will try to review it on the
plane so can ask you any questions in person this coming week.

-Karl

> Controls to modify email message based on diff size
>
> * commit-email.pl.in
> Added new commandline arguments (-ds, -dl)
> -ds: diff_size (max) - overrides default of 1_000_000
> -dl: diff_location - added to email body if set
> $max_diff_size: New variable
> check_diff(): New function to modify body based on diff size
> Added call to check (and possibly truncate) size of @difflines
> Index: tools/hook-scripts/commit-email.pl.in
> ===================================================================
> --- tools/hook-scripts/commit-email.pl.in (revision 12807)
> +++ 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_diff_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.
> @@ -108,7 +111,9 @@
> '-l' => 'log_file',
> '-m' => '',
> '-r' => 'reply_to',
> - '-s' => 'subject_prefix');
> + '-s' => 'subject_prefix',
> + '-ds' => 'diff_size',
> + '-dl' => 'diff_location');
>
> while (@ARGV)
> {
> @@ -367,6 +372,7 @@
> push(@body, "Log:\n");
> push(@body, @log);
> push(@body, "\n");
> +&process_diff();
> push(@body, map { /[\r\n]+$/ ? $_ : "$_\n" } @difflines);
>
> # Go through each project and see if there are any matches for this
> @@ -500,6 +506,8 @@
> " -m regex Regular expression to match committed path\n",
> " -r email_address Email address for 'Reply-To:'\n",
> " -s subject_prefix Subject line prefix\n",
> + " -ds diff_size Max size of diff content\n",
> + " -dl diff_location String to be put before diff content\n",
> "\n",
> "This script supports a single repository with multiple projects,\n",
> "where each project receives email only for commits that modify that\n",
> @@ -518,7 +526,12 @@
> "a list of email addresses on the command line. If you do not want\n",
> "a project that matches the entire repository, then use a -m with a\n",
> "regular expression before any other command line options or email\n",
> - "addresses.\n";
> + "addresses.\n",
> + "\n",
> + "The maximum amount of diff content and hence the size of the email\n",
> + "can be set using the -ds option and a diff 'location' can be set\n",
> + "using the -dl option like so:\n",
> + "-ds 'http://svn.collab.net/viewcvs/svn/?view=rev&rev=12798'\n";
> }
>
> # Return a new hash data structure for a new empty project that
> @@ -598,3 +611,30 @@
> return @output;
> }
> }
> +
> +# Check size of @difflines and truncate if necessary
> +# Add diff_location (e.g, a ViewCVS URL) if specified
> +sub process_diff
> +{
> + # all projects have the same diff_location
> + if ($project_settings_list[0]->{diff_location})
> + {
> + push(@body, "$project_settings_list[0]->{diff_location}\n");
> + }
> +
> + if ($project_settings_list[0]->{diff_size})
> + {
> + $max_diff_size = $project_settings_list[0]->{diff_size};
> + }
> +
> + for (my ($line, $size) = (0, 0); $line <= $#difflines; $line++)
> + {
> + if (($size + length $difflines[$line]) > $max_diff_size)
> + {
> + splice(@difflines, 0, $#difflines,
> + "\n(Diff too large to include in email. See above)");
> + last;
> + }
> + $size += length($difflines[$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 Sun Jan 23 21:00:12 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.