When can a hook make a change to the repository?
[email protected] 12 Nov 2005 18:43:55 -0600
| Newsgroups | gmane.comp.version-control.subversion.devel,gmane.mail.eyebrowse.user |
|---|---|
| Message-ID | <[email protected]> |
[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 <[email protected]> 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