views:

209

answers:

1

I would like to use a pre-commit hook that prevents developers from setting svn:mergeinfo on non-root directories. That is, I want to enforce that svn:mergeinfo can only be set on directories like "trunk" or "branches/branchName". Developers sometimes need to be "reminded" that it's not good practice to use a subdirectory of the root as a merge target (per the best practices listed here). Does anyone have such a hook script or know where I could find one? I am in a windows environment, so batch or powershell would be preferable, but anything would certainly be helpful.

+4  A: 

First of all, I'd recommend using perl or python to do the task, windows batch leaves much to be desired.

You can use some example script from http://svn.apache.org/repos/asf/subversion/trunk/tools/hook-scripts/ to start from. For example, verify-po.py script checks file encodings and commit-access-control.pl.in checks whether author has permissions to commit. You'd probably employ svnlook diff in your script (as in the latter one) to get changed properties for directories and go through the corresponding paths whether they're branches or tags using regular expression.

Update

Found enforcer pre-commit hook script which seems to be what you're looking for.

What this script does is it uses svnlook to peek into the transaction is progress. As it sifts through the transaction, it calls out to a set of hooks which allow the repository administrator to examine what is going on and decide whether it is acceptable.

It contains several methods and verify_property_line_added() among them, since it's called for each line that is added to a property on a file.

Pmod
Looks like this is going to be the most likely solution and thus the bounty winner, unless anyone else can come up with something.
Charles
By the way, after your question I began interested in svn hooks, and I am going to implement some (starting with forbidding commits with no log message), and probably will reach the checking properties on commit - then will put here an another update.
Pmod