[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: Hyrum K. Wright <hyrum_wright_at_mail.utexas.edu>
Date: 2006-12-28 16:59:50 CET

Lars Müller wrote:
> On Wed, Dec 06, 2006 at 10:40:33AM -0500, C. Michael Pilato wrote:
>> 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.
>
> Attached as diff a version based on rev 22589 with a --stdout command
> line option. I reverted all former and not superfluous changes made
> with rev 22589.
>
> Your second suggestion is already the case as the -l option uses the
> same @head as stdout does.
>
> By intention I did not remove the -l option. This is up to one of the
> subversion committers.
>
> Might some users use -l to pass the message to a file and afterwards
> perform modifications on this file? If this is the case it might be
> usefull to stay with -l further. Yes, these users might even pipe the
> output to their modifying commands or redirect the output to a file.
> The only potential problem I see is after an update to a newer
> subversion version. A missing -l option might then break existing
> scripts.
>
> While testing I ran into the problem of a non valid mbox output as soon
> as the locale is set to something non US or non POSIX. The problem is
> the first line of the output. I first thought about circumventing this
> by setting the locale to POSIX while output the particular line. But we
> might consider to document this problem instead.

Ping...

Has anybody looked at this part of Lars' patch? If nothing happens,
I'll file an issue in a few days.

-Hyrum

> ------------------------------------------------------------------------
>
> Index: commit-email.pl.in
> ===================================================================
> --- commit-email.pl.in (revision 22589)
> +++ commit-email.pl.in (working copy)
> @@ -38,19 +38,18 @@
>
> use strict;
> use Carp;
> -my ($sendmail, $smtp_server, $stdout);
> +my ($sendmail, $smtp_server);
>
> ######################################################################
> # Configuration section.
>
> -# 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
> +# 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
> # email should be used.
> +# Using --stdout on the command line overwrites both.
> #$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";
> @@ -92,10 +91,10 @@
> $ok = 0;
> }
> }
> - if (not (defined $sendmail xor defined $smtp_server xor defined $stdout))
> + if (not (defined $sendmail xor defined $smtp_server))
> {
> - warn "$0: exactly one of \$sendmail, \$smtp_server, or \$stdout ",
> - "must be set, edit $0.\n";
> + warn "$0: exactly one of \$sendmail or \$smtp_server must be ",
> + "set, edit $0.\n";
> $ok = 0;
> }
> exit 1 unless $ok;
> @@ -142,7 +141,8 @@
> '-m' => '',
> '-r' => 'reply_to',
> '-s' => 'subject_prefix',
> - '--diff' => '');
> + '--diff' => '',
> + '--stdout' => '');
>
> while (@ARGV)
> {
> @@ -156,7 +156,7 @@
> }
>
> my $value;
> - if ($arg ne '--revprop-change')
> + if ($arg ne '--revprop-change' and $arg ne '--stdout')
> {
> unless (@ARGV)
> {
> @@ -204,6 +204,10 @@
> {
> $current_project->{show_diff} = parse_boolean($value);
> }
> + elsif ($arg eq '--stdout')
> + {
> + $current_project->{stdout} = 1;
> + }
> else
> {
> die "$0: internal error:"
> @@ -518,6 +522,7 @@
> my $subject_prefix = $project->{subject_prefix};
> my $subject = $subject_base;
> my $diff_wanted = ($project->{show_diff} and $mode eq 'commit');
> + my $stdout = $project->{stdout};
>
> if ($subject_prefix =~ /\w/)
> {
> @@ -533,7 +538,7 @@
> {
> $mail_from = "$mail_from\@$hostname";
> }
> - elsif (defined $smtp_server)
> + elsif (defined $smtp_server and ! defined $stdout)
> {
> die "$0: use of either `-h' or `--from' is mandatory when ",
> "sending email using direct SMTP.\n";
> @@ -598,8 +603,13 @@
> @difflines = map { /[\r\n]+$/ ? $_ : "$_\n" } @difflines;
> }
>
> - if (defined $sendmail and @email_addresses)
> + if (defined $stdout)
> {
> + print @head, @body;
> + print @difflines if $diff_wanted;
> + }
> + elsif (defined $sendmail and @email_addresses)
> + {
> # Open a pipe to sendmail.
> my $command = "$sendmail -f'$mail_from' $userlist";
> if (open(SENDMAIL, "| $command"))
> @@ -628,11 +638,6 @@
> 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/)
> @@ -679,6 +684,7 @@
> " -s subject_prefix Subject line prefix\n",
> " --diff y|n Include diff in message (default: y)\n",
> " (applies to commit mode only)\n",
> + " --stdout Spit the message in mbox format to stdout.\n",
> "\n",
> "This script supports a single repository with multiple projects,\n",
> "where each project receives email only for actions that affect that\n",
> @@ -718,7 +724,8 @@
> match_regex => '.',
> reply_to => '',
> subject_prefix => '',
> - show_diff => 1};
> + show_diff => 1,
> + stdout => 0};
> }
>
> sub parse_boolean

Received on Thu Dec 28 17:00:08 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.