On Wed, Jan 5, 2011 at 5:03 PM, <eric.berg@barclayscapital.com> wrote:
Dave, if you look into how the hooks work, basically, they are passed a repo path and a transaction id that, using svnlook, gives you access to copies of the working files, so it doesn't matter where the hooks run, nor is there any requirement for server/client communication.

I've written quite a few hooks. I have a hook script that implements watches. There are many post-commit hooks that set watches, but mine allows the users to set their own by storing the watchlist for each user in the Subversion repository. I use "svnlook cat" to parse out the user's watch list to see if the file being committed is part of the watch. I can do this without having to write the watchlist file into a directory.

However, I take it that in order to run the tests, you need these files written to a directory, and you may need dependent files there too. That starts getting a bit more complex than what "svnlook" was built for. In theory, you could checkout a working directory on a hook script, then use "svnlook cat" to update the files that are being committed, and run your tests. It's complex, and can take a long time.

Even after all of that, Subversion captures STDOUT and STDERR and they don't get printed out to a console. If you want to see them, you'll have to capture them and then either write them to a logfile, or email them.

Though I do love immediate checkins, I'm not sure where you're going when you suggest that our validations might be better handled some way other than by hooks.  That appears to be the whole reason to have such hooks:  to validate files before allowing a checkin.

How long does it take your pre-commit hook to run? Even a few seconds can seem like an eternity to a developer who is making a few minor changes. If every time a developer does a commit, they have to wait, they simply will stop making commits when they should. And, they'll learn to hate Subversion because it is slow and buggy.

Remember that Subversion is a version control system which means you can undo stuff that should never have been committed in the first place. Doing tests during the build cycle has lots of advantages:

* You have room to checkout your entire project and have access to all the files. That can make running your tests much simpler to do.
* You can use Hudson as your framework (or another build server). That means the reporting, running, and checking the results are all done for you. There's no reinventing the wheel.
* Your commits are now much faster.
* Your tests have their own environment and won't interfere with Subversion
* You have a complete log of your tests, and you can review it and see if things are improving.
* You have time and resources for more thorough testing
* You can notify the entire team when there's an issue. There's always a good chance that the problem isn't in the file being committed, but is located elsewhere.
* Most importantly, you'll make your life a lot easier. All you have to do is write the tests and not worry about how you'll run the tests, or how you'll get the output from the tests.

It is definitely possible to do what you want, but it will take a lot of work and will probably cause more problems than it is worth..

--
David Weintraub
qazwart@gmail.com