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

Re: [PATCH] commit-email.pl to produce mbox messages to stdout

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: 2006-12-06 16:40:33 CET

So, I like the idea of this patch. And the implementation seems fine,
as far as my testing and review can tell. Committed in r22589.

   Sending hook-scripts/commit-email.pl.in
   Transmitting file data .
   Committed revision 22589.

I would recommend now that we add a command-line option for forcing
stdout mode. And then I would recommend one of two followup actions:

   * Either deprecate the -l option now that folks can use
     commit-email.pl --stdout >> logfile (and get mbox format!)

   * Or at least make the -l option add the mbox From header.

(I prefer the former.)

Lars Müller wrote:
> Hi,
>
> I've modified tools/hook-scripts/commit-email.pl.in to produce mbox
> formated output if stdout is defined instead of sendmail or smtp_server.
>
> This format is useable by mailman's arch tool to recreate an archive
> from scratch. Without the leading 'From ' line the created output is not
> recognized as mbox. If no 'Date: ' line is included mailman's arch uses
> the current date for every message.
>
> Lars
>
>
> ------------------------------------------------------------------------
>
> Index: tools/hook-scripts/commit-email.pl.in
> ===================================================================
> --- tools/hook-scripts/commit-email.pl.in (revision 22432)
> +++ tools/hook-scripts/commit-email.pl.in (working copy)
> @@ -38,17 +38,19 @@
>
> use strict;
> use Carp;
> -my ($sendmail, $smtp_server);
> +my ($sendmail, $smtp_server, $stdout);
>
> ######################################################################
> # Configuration section.
>
> -# Sendmail path, or SMTP server address.
> -# You should define exactly one of these two configuration variables,
> -# leaving the other commented out, to select which method of sending
> +# Sendmail path, SMTP server address, or stdout.
> +# You should define exactly one of these three configuration variables,
> +# leaving the other commented out, to select which method of creating
> # email should be used.
> #$sendmail = "/usr/sbin/sendmail";
> $smtp_server = "127.0.0.1";
> +# Use stdout if you like to get the message in mbox format to stdout.
> +#$stdout = 1;
>
> # Svnlook path.
> my $svnlook = "@SVN_BINDIR@/svnlook";
> @@ -90,10 +92,10 @@
> $ok = 0;
> }
> }
> - if (not (defined $sendmail xor defined $smtp_server))
> + if (not (defined $sendmail xor defined $smtp_server xor defined $stdout))
> {
> - warn "$0: exactly one of \$sendmail or \$smtp_server must be ",
> - "set, edit $0.\n";
> + warn "$0: exactly one of \$sendmail, \$smtp_server, or \$stdout ",
> + "must be set, edit $0.\n";
> $ok = 0;
> }
> exit 1 unless $ok;
> @@ -123,6 +125,7 @@
> my $propname;
>
> my $mode = 'commit';
> +my $date;
> my $diff_file;
>
> # Use the reference to the first project to populate.
> @@ -355,7 +358,7 @@
> # Get the author, date, and log from svnlook.
> my @infolines = &read_from_process($svnlook, 'info', $repos, '-r', $rev);
> $author = shift @infolines;
> - my $date = shift @infolines;
> + $date = shift @infolines;
> shift @infolines;
> my @log = map { "$_\n" } @infolines;
>
> @@ -537,6 +540,18 @@
> }
>
> my @head;
> + if (defined $stdout)
> + {
> + my ( $h_date, $h_year, $h_time, $h_day, $h_offset, $h_week_day, $h_short_date, $h_month_day, $h_month_name );
> +
> + $h_date = $date;
> + $h_date =~ s/[(),]//g;
> +
> + ( $h_short_date, $h_time, $h_offset, $h_week_day, $h_month_day, $h_month_name, $h_year ) = split(/ /, $h_date);
> +
> + push(@head, "From $mail_from $h_week_day $h_month_name $h_month_day $h_time $h_year\n");
> + push(@head, "Date: $h_week_day, $h_month_name $h_month_day $h_year $h_time $h_offset\n");
> + }
> push(@head, "To: $to\n");
> push(@head, "From: $mail_from\n");
> push(@head, "Subject: $subject\n");
> @@ -613,6 +628,11 @@
> handle_smtp_error($smtp, $smtp->dataend());
> handle_smtp_error($smtp, $smtp->quit());
> }
> + elsif (defined $stdout)
> + {
> + print @head, @body;
> + print @difflines if $diff_wanted;
> + }
>
> # Dump the output to logfile (if its name is not empty).
> if ($log_file =~ /\w/)

-- 
C. Michael Pilato <cmpilato@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand

Received on Wed Dec 6 16:40:55 2006

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.