SVN provides the ability to send email notification after a commit. This along with other tools, is presented in the form of hook_scripts.

When we create a new svn repository, templates for these hook scripts are created for our use at $SVN_REPO_ROOT/hooks.

The respective executables in perl/python/ruby and example configuration files for the hook scripts will be at $SVN_INSTALL_DIR/tools/hook-scripts and $SVN_INSTALL_DIR/contrib/hook-scripts.

To configure svn repository to send email after a commit with the python tool, mailer.py: (the following steps are from this useful blog)

  • Copy mailer.py to $HOME/bin. Following paths are good for test-sgsubmit.
    cp /usr/share/doc/subversion-1.5.5/tools/hook-scripts/mailer/mailer.py $HOME/bin/
    chmod +x $HOME/bin/mailer.py
    
  • Copy the mailer.conf to your svn repo's conf dir.
    cp /usr/share/doc/subversion-1.5.5/tools/hook-scripts/mailer/mailer.conf.example $TMPSVNROOT/conf/mailer.conf
    
  • Modify the mailer.conf contents. Following is a light-weight configuration, we can tune it in as detail as needed. The rest of the config options are the defaults.
    [general]
    mail_command = /usr/sbin/sendmail
    [defaults]
    diff = /usr/bin/diff -u -L %(label_from)s -L %(label_to)s %(from)s %(to)s
    commit_subject_prefix = [svn-commit]
    propchange_subject_prefix =
    lock_subject_prefix =
    unlock_subject_prefix =
    from_addr = blazerid
    to_addr = blazerid
    reply_to = blazerid
    
  • Enable the hook, post-commit for sending email notifications after commits.
    cp $TMPSVNROOT/hooks/post-commit.tmpl $TMPSVNROOT/hooks/post-commit
    chmod +x $TMPSVNROOT/hooks/post-commit
    
  • Modify the contents of the hook, post-commit with the following: (comment any other hooks, commit-email.pl and log-commit.py)
    REPOS="$1"
    REV="$2"
    MAILER_CONF=$TMPSVNROOT/conf/mailer.conf
    $HOME/bin/mailer.py commit "$REPOS" "$REV" "$MAILER_CONF"
    #commit-email.pl "$REPOS" "$REV" commit-watchers@example.org
    #log-commit.py --repository "$REPOS" --revision "$REV"
    
  • Mention the correct path to your svn repo instead of $TMPSVNROOT
  • Do a commit and get the notification as an email