svnpre-commit-hookmergeinfo

How to set a trigger to prevent commits to SVN with mergeinfo property?


I'd like to avoid creating svn mergeinfo property on anything but the root of branches. We have a trunk branch and some other branches.

Assuming I know absolutely nothing about svn triggers, what steps do I need to follow to setup a pre-commit hook that prevents additions of mergeinfo properties to anything but the root of branches?

The trunk is located in the repository's base "/trunk", and all branches are in "/branches/foo"


Solution

  • Basically, you need to define a SVN pre-commit hook. First though, read about hooks in general.

    You will likely want to start with copying the pre-commit.tmpl file to pre-commit, and implement the logic in there.

    You will likely want to examine the diff of the currently executing transaction for lines like: Added: svn:mergeinfo

    Since the information about which file this was added for is on a different line, you may need a more complex processing tool than grep - perhaps a simple perl script.

    When you determine that a transaction has an added property that you don't want, you can block the commit; or, if you are especially daring, you could try to modify the transaction and continue.