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

When can a hook make a change to the repository?

From: <kfogel_at_collab.net>
Date: 2005-11-13 01:43:55 CET

[I've left this in the thread, but changed the subject line and CC'd
users@subversion, since I think it might be of interest there.
Probably this should become a FAQ item, if it's not already.]

Ximon Eighteen <ximon.eighteen@int.greenpeace.org> writes:
> > Post-commit hook script checks to see a folder with the name of the
> >branch exists, and if not creates it, and does an inplace checkout as
> >described in the faq to make it an active svn workdir to the branch
> >in the repository. It then copies all the source files
> >(php/javascript/html templates) into this folder, and does a svn add
> >on these, followed by a commit (can you see the issue yet?)
>
> It's my understanding that hooks are not allowed to change the
> repository.

That's not quite right; the actual guidelines are a bit more complex.

In the pre-commit hook, you should not change versionable items in the
txn being committed, because there would be no way for the working
copy to find out about your changes -- the working copy would think it
was up-to-date after the commit, when in fact it would not be.
(However, note that it's not necessarily bad for pre-commit to set or
change unversioned revprops on the txn, as long as it is careful with
things like svn:date.)

In post-commit, it's fine to make further changes to the repository,
but you should make sure you don't accidentally start a hook loop:
whatever change your post-commit hook makes, it should not be of the
sort that would cause post-commit to be invoked again in such a way
that it would want to make the same kind of change, thus resulting in
another invocation of post-commit... You get the idea :-).

-Karl

-- 
www.collab.net  <>  CollabNet  |  Distributed Development On Demand
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Sun Nov 13 03:05:14 2005

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.