Sep 15 2008
I am doing some work with Subversion now so I got a chance to play with some hook functionality. Unfortunately, 99.99993% of all information out there for Subversion seems to be directed towards Linux, but after an appropriate amount of head-banging I got it working. Our dev server has Subversion installed with a repository holding our code. Each developer has installed TortoiseSVN (which is a Windows GUI client for the server) and checked out the code for local development. Then, on the server we also checked out the trunk folder into our wwwroot for IIS. The problem was, ever time we committed code from our local machine and wanted to run it on the dev server, we needed to remote into the server to update the code checked out to the wwwroot folder.To automate that process, you can use one of the several hooks for subversion. In your repository folder, you will find a directory called "hooks". Here are the possible hooks you can implement:
- start-commit - Notification of the beginning of a commit.
- pre-commit - Notification just prior to commit completion.
- post-commit - Notification of a successful commit.
- pre-revprop-change - Notification of a revision property change attempt.
- post-revprop-change - Notification of a successful revision property change.
- pre-lock - Notification of a path lock attempt.
- post-lock - Notification of a successful path lock.
- pre-unlock - Notification of a path unlock attempt.
- post-unlock - Notification of a successful path unlock.
[code]D:\Subversion\bin\svn.exe update D:\wwwroot\ --quiet --non-interactive --username brad --password mypass --config-dir D:\svnrepos\myrepo\conf\[/code]I am calling the SVN.exe executable (with a full path) and passing in the update switch. The second argument is the path to the checked out code in the wwwroot I want updated. --quiet suppresses any output since it won't be seen anyway, and --non-interactive tells it that there is no user to interact with. --username, --password, and -config-dir should be fairly self-explanatory. I originally created the batch file without the username, password, and config-dir arguments and it wouldn't run. After much fiddling (and the addition of those arguments) it began working. I removed the arguments one at a time to see which one was the magical fix, but to my amazement, the hook continued to run even after I restored it to its previously non-working state. Finally I got tired of trying to figure out why I couldn't get it to NOT work and gave up-- putting the batch file back. I figured more arguments would be safer than fewer. I will say, it is very frustrating to figure out why a hook isn't running. There are no visible errors or log entries (that I know of). It just does nothing and you sit and scratch your head. Also, I believe there is a program in Linux called "env" that will allow you to run something in an empty environment, but I was unable to find an equivalent way to test the file in Windows.