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

Re: Do commit hooks work with the file:// protocol?

From: Andy Levy <andy.levy_at_gmail.com>
Date: Tue, 8 Feb 2011 12:34:18 -0500

On Tue, Feb 8, 2011 at 12:19, Jonathan Reeve
<Jonathan.Reeve_at_practicallaw.com> wrote:
> I want to be able to prevent commits to a repository in some circumstances. I've set up a local svn repository to test, but my commit hook doesn't get called.
>
> I'm using the file:// protocol. Should hooks work with that?
>
> There's a transcript of how to reproduce the issue here: http://stackoverflow.com/questions/4934990/

It should work. but because they're executed on the same computer that
you ran the svn command (maybe even the same cmd session) from things
can get odd. Have you tried calling exit without the /B switch?

In a "normal" environment, this should be a non-issue, as you'd have
an actual server where the hooks execute.

For completeness in the archives (and those who can't/don't wish to go
to the URL above), the transcript follows:

C:\>mkdir \testsvn
C:\>mkdir \testsvn\repos
C:\>cd \testsvn\repos
C:\testsvn\repos>svnadmin create --fs-type fsfs /testsvn/repos
C:\testsvn\repos>cd \testsvn
C:\testsvn>mkdir source
C:\testsvn>cd source
C:\testsvn\source>echo This is a readme file.>readme.txt
C:\testsvn\source>svn import file:///testsvn/repos/somemodule -m
"Imported somemodule"
Adding readme.txt
Committed revision 1.

C:\testsvn\source>cd \testsvn\repos\hooks
C:\testsvn\repos\hooks>copy con pre-commit.bat
echo Commits disabled! 1>&2
exit /b 1
^Z
        1 file(s) copied.

C:\testsvn\repos\hooks>md \testsvn\checkout
C:\testsvn\repos\hooks>cd \testsvn\checkout
C:\testsvn\checkout>svn checkout file:///testsvn/repos/somemodule
A somemodule\readme.txt
Checked out revision 1.

C:\testsvn\checkout>cd somemodule
C:\testsvn\checkout\somemodule>echo This is line 2 of the readme
file.>>readme.txt
C:\testsvn\checkout\somemodule>svn status -u
M 1 readme.txt
Status against revision: 1

C:\testsvn\checkout\somemodule>svn commit -m "This should fail if the
pre-commit hook works..."
Sending readme.txt
Transmitting file data .
Committed revision 2.
Received on 2011-02-08 18:35:37 CET

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.