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

Re: Environment variables lost when post-commit hook is executed

From: David Weintraub <qazwart_at_gmail.com>
Date: Thu, 25 Sep 2008 13:12:15 -0400

On Thu, Sep 25, 2008 at 9:15 AM, vinay i <vinay.indresh_at_gmail.com> wrote:
> Hi
> I am trying to print repository name and revision number in post-commit
> script. When I am committing files I guess post-commit is redirecting the
> STDOUT to some other shell. How do I print the statements in the console
> where I am doing the commit?

STDOUT is simply dropped and not redirected. STDERR is captured and is
sent back to the client on hook failures only. That's pretty standard
for hook/triggers in many applications. You normally want the hook to
run silently and not have to worry about spurious output because you
forgot to redirect something that prints out to STDOUT.

However, it doesn't mean you can't have your program do any
communication at all. Your hook script can still:

* Write to the Syslog (Unix) or Events Viewer (Windows)
* Write to a logfile
* Send emails or pages

With a bit of work, you could have your hook write to another process
and have this process write to the console if you really need this
information printed out to a console.

The main thing is that printing to STDOUT is not the default behavior
of a Subversion hook, but that doesn't mean it can't communicate with
your what it's doing.

In Perl, you can use the "select" statement to select another file
handle besides STDOUT as the default for your "print" statements.
There might be a similar mechanism in Python. That way, you only have
to add a few stray statements to your hook script instead of going
through the entire hook script and changing everywhere it prints to
STDOUT:

    open (LOG, ">$logfile") or die "Can't open $logfile";
    print "This prints to STDOUT\n";
    select (LOG);
    print "This prints to file $logfile\n";

--
David Weintraub
qazwart_at_gmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-09-25 19:12:40 CEST

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

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