Search code examples
batch-fileasynchronoussvnvisualsvn-server

SVN hooks don't execute asynchronous


On our SVN server (Windows / VisualSVN Server) I've created a Post-Commit script to auto update a local working copy on the server (for preview purposes). The Post-Commit script contains something like this:

svn.exe cleanup .....
svn.exe update .....

This works great. However, we have some larger repositories, where this takes a while. I'd like to run this script asynchronous when committing something. Therefore I've moved the SVN instructions inside an external batch file and try to use CMD /C or Start command to accomplish this.

start "" "d:\svn\update-repository.bat"

or

cmd /c "d:\svn\update-repository.bat"

or even

start cmd /c "d:\svn\update-repository.bat"

does not give asynchronous performance. It still remains committing until the entire repository is updated on the server.

Any ideas?


Solution

  • I think the command run by svn server will not fully return until it is complete - and that means the original cmd will be sitting there allowing you to run other commands, but otherwise waiting for the spawned cmd shall to complete. Only then does the "session" (for want of a better word) complete and return control to Subversion.

    I would write the commands you want to run to a file, and then use an externally spawned command (eg a scheduled task) to run the saved command periodically (note, delete or rename the file after each execution). This decouples it from the subversion server's processing.