You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by David Weintraub <qa...@gmail.com> on 2011/11/03 17:46:52 UTC

post-commit hook problems with SMTP

I've written a Perl post-commit hook that emails out via SMTP. I was
getting the following error when I try to do a commit:

    Sending        subversion/README
    Transmitting file data .svn: Commit failed (details follow):
    svn: MERGE of '/mfxcm/trunk/subversion': 200 OK (http://source)

The commit actually had worked, but the revision of my working copy
wasn't updated until I did a "svn up":

    $ svn commit -m"Finding what's causing commit errors. I think it's
the post-commit script"
    Sending        subversion/README
    Transmitting file data .svn: Commit failed (details follow):
    svn: MERGE of '/mfxcm/trunk/subversion': 200 OK (http://source)
    david@DaveBook.local:~/workspace/svn-cm-trunk/subversion
    $ svn up
    G    README
    Updated to revision 94.

I've played around with my post-commit script, and everything is find
until I do:

        my $smtp = Net::SMTP->new(
            Host  => $self->SmtpHost,
            Debug => $main::debugLevel,

Then, I get the MERGE error again. If I take out the SMTP portion of
the script, everything works just fine. If I put in starting SMTP, it
fails.

I know the script actually works because I print out the command to
execute my post-commit hook, and I can run it from the command line
without any problems. It only gets that MERGE error if run as a
post-commit hook.

What exactly does that MERGE error mean, and why do I get it when
Subversion runs the post-commit hook vs. when I run the same thing
from the command line?

-- 
David Weintraub
qazwart@gmail.com

Re: post-commit hook problems with SMTP

Posted by David Weintraub <qa...@gmail.com>.
On Thu, Nov 3, 2011 at 7:27 PM, Daniel Shahaf <d....@daniel.shahaf.name> wrote:
> I think MERGE is the DAV command that corresponds to "Commit this
> transaction (i.e., promote it to a revision)".
>
> Anyway: when svn runs the hook, it only looks at its exit code, stderr,
> and stdout.  So, check how these three change with/without the Net::SMTP
> invocation.
>
> You probably know that there's a FAQ entry recommending the proper way
> to test a hook: as the server's user, with an empty environment, etc.

Yup. Followed the procedure and it works from the command line.

I traced the error through Net::SMTP to a call to "$obj->response" at
that line, it never finishes Net::SMTP. The "response" is from
Net::Cmd, so I'll have to trace it in there. I suspect that Net::Cmd
croaks or something, and since the post-commit command never
completes, Subversion gives me the MERGE error.

Someone suggested I try Mail::Sendmail. I chose Net::SMTP because
that's a standard Perl module, but if it doesn't work, I'll switch to
Mail::Sendmail.
-- 
David Weintraub
qazwart@gmail.com

Re: post-commit hook problems with SMTP

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
David Weintraub wrote on Thu, Nov 03, 2011 at 12:46:52 -0400:
> I've written a Perl post-commit hook that emails out via SMTP. I was
> getting the following error when I try to do a commit:
> 
>     Sending        subversion/README
>     Transmitting file data .svn: Commit failed (details follow):
>     svn: MERGE of '/mfxcm/trunk/subversion': 200 OK (http://source)
> 
> The commit actually had worked, but the revision of my working copy
> wasn't updated until I did a "svn up":
> 
>     $ svn commit -m"Finding what's causing commit errors. I think it's
> the post-commit script"
>     Sending        subversion/README
>     Transmitting file data .svn: Commit failed (details follow):
>     svn: MERGE of '/mfxcm/trunk/subversion': 200 OK (http://source)
>     david@DaveBook.local:~/workspace/svn-cm-trunk/subversion
>     $ svn up
>     G    README
>     Updated to revision 94.
> 
> I've played around with my post-commit script, and everything is find
> until I do:
> 
>         my $smtp = Net::SMTP->new(
>             Host  => $self->SmtpHost,
>             Debug => $main::debugLevel,
> 
> Then, I get the MERGE error again. If I take out the SMTP portion of
> the script, everything works just fine. If I put in starting SMTP, it
> fails.
> 
> I know the script actually works because I print out the command to
> execute my post-commit hook, and I can run it from the command line
> without any problems. It only gets that MERGE error if run as a
> post-commit hook.
> 
> What exactly does that MERGE error mean, and why do I get it when
> Subversion runs the post-commit hook vs. when I run the same thing
> from the command line?

I think MERGE is the DAV command that corresponds to "Commit this
transaction (i.e., promote it to a revision)".

Anyway: when svn runs the hook, it only looks at its exit code, stderr,
and stdout.  So, check how these three change with/without the Net::SMTP
invocation.

You probably know that there's a FAQ entry recommending the proper way
to test a hook: as the server's user, with an empty environment, etc.

> 
> -- 
> David Weintraub
> qazwart@gmail.com