Still reading? Okay, here's the problem: like many users of subversion (svn for short) I like getting e-mail diffs from svn after each commit, but sometimes, like after a move, copy, or vendor drop, they are too big. Way too big: they have even caused out of memory conditions on my subversion server. They have sent emails on the order of 12 megs, and that was only limited by the emailer, not by any part of subversion so far as I know.
Why? by default, subversion ships with some hook script templates that you can configure. The templates point to some simple, easy to use perl scripts, so you'd think that's what the subversion developers are endorsing. When I asked about this on the mailing list, I got two responses, both suggested I use something else, and one even used the phrase "bit rot". The take-home message: don't use those perl scripts! Instead, here's a more modern way to get your emails and limit the diff sizes while your at it:
- Download and unzip the patched mailer script.
- Check the first line of the script and make sure that it matches the path to python on your system. If not, modify the scrpt, so that it does.
- As it is, the script omits diffs if they are larger than 50k. If you want to change that, look for and modify the line: MAX_DIFF_SIZE = 50000.
- Put the patched mailer script somewhere sensible. /usr/local/bin is not bad. ~/bin/ is sensible as well, if your repo is installed somewhere in your home dir.
- Edit your post-commit hook (in your repository's hooks directory) so that it looks like this:
/full/path/to/svn-mailer.py commit "$REPOS" "$REV"
- Now the last step is the tricky one: Somewhere on your system there is a mailer.conf.example file. You can usually find it using "locate mailer.conf.example". Copy that to your subversion repo's conf directory and call it mailer.conf. It is well commented and you should be able to go through and make changes logically, but it pays to be careful. I recommend setting generate_diffs to modify, as that prevents diffs from being generated on files that are simply copied, added or deleted, but people's preferences vary on this one.
- To test the configuration, run the post-commit script with complete path to the repository and the last revision number as arguments. That should send an email for the last commit.
If you like everything about this except the bit about limiting the diff sizes, you can, of course, use the mailer.py that came with subversion instead of the patched version, just use locate to find it on your system. Everything else stays the same.
For even more control, you can also look into SVN::Notify.