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

Re: post-commit hook

From: Stefan Schwarzbach <Schwarzbach_at_SilentDreams.de>
Date: 2006-01-04 18:48:45 CET

Ryan Schmidt schrieb:
>
> On Jan 3, 2006, at 21:58, K Y wrote:
>
>> Stefan Schwarzbach <Schwarzbach@SilentDreams.de> wrote:
>>
>>> I use the pre-commit hook also to do some checks, f.e. to check if the
>>> changelog text is empty or there is a case sense conflict. If something
>>> with the commit went wrong due to these checks, I write an error
>>> message
>>> to stderr and exit the hook script with != 0. The client who tried to
>>> commit his changes will get the error message I wrote to stderr as
>>> reply
>>> to his commit trial.
>>
>> Exactly. If you perform these tests in the post-commit hook, the
>> commit of the files has completed - and then you are trying to also
>> commit the logs afterwords (i think i understood your scenario
>> correctly).
>>
>> With a pre-commit hook - you can check what you need - run your test
>> shells and commit all of the changes as well as the test log files at
>> once - if successful.
>
> It doesn't really work that way with a pre-commit hook though. You
> cannot modify the transaction that's in progress; doing so would break
> the user's working copy. Instead, regardless of whether you're doing
> it in a pre- or a post-commit hook, your hook must maintain its own
> working copy, apply the desired changes, and commit it as a second
> revision. You should also clearly engineer your hook so that it does
> not react to the automatic commit that you're doing, lest you cause an
> endless loop.
>

You are right. Modifying the transaction that's in progress won't work
in the pre-commit hook (a also in the post-commit hook). But I, as
always discussed for the post-commit hook, I think it would be possible
to start another process to create a new transaction for log files or
something like that.
Nevertheless I think the starting problem was about to inform the people
about errors. You can do that in the pre-commit hook by writing to
stderr. You could put the error log a new ticket in your bug tracker
system and notify the person comitting the transaction with an url to
this ticket via stderr. If you can also return a message to the client
via stderr in post-commit (I'm not sure about that), this could be done
in pre-commit or in post-commit, like you prefer.

Grettings,
Stefan Schwarzbach

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed Jan 4 18:56:31 2006

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.