Subversion is a great version control system, particularly in the ease with which it processes data at various points of the repository management process. You can have scripts handle data after a commit has been made, before a commit has been made, on locking or unlocking files, and so forth. All of this is done via hooks, which are part of the subversion repository structure itself. Hooks are triggered by a repository event. For instance, if you had a subversion repository as /subversion/repos/packages then the hooks would be in the /subversion/repos/packages/hooks directory.

In this hooks directory are a number of template files. These files exist as examples only. So if you wanted to write a script that would e-mail some subversion data to you on every commit, you would copy the post-commit.tmpl file to post-commit, make it executable, and edit it as needed.

A number of these scripts are available from the subversion site, as well as other user-contributed scripts and tools for subversion. You can view many of these scripts at http://subversion.tigris.org/tools_contrib.html. Of interest at the moment is the post-commit e-mail script, commit-email.pl. Download the file and place it somewhere such as /usr/local/bin/ and make it executable. In the hooks/post-commit script, add to the end of the file the following:

REPOS="$1"
REV="$2"
/usr/local/bin/commit-email.pl "$REPOS" "$REV" --from svn@myhost.com -s \
  "SVN commit in packages" joe@myhost.com

This will execute the commit-e-mail.pl script with a few parameters, namely the repository name and the revision of the commit. It will send the e-mail from svn@myhost.com with the specified subject line, and send the mail to joe@myhost.com; this could be either a specific user or a mailing list.

If you look at the other scripts on the site, you'll see a number of scripts that could be of interest in the management of your subversion repository. There are scripts that can do certain checks prior to even fully committing the data to subversion, such as the various pre-commit check scripts.

Open Sourcery This was published in Open Sourcery, check every Monday for more stories

Related links

Leave a comment

You must read and type the 6 chars within 0..9 and A..F

* indicates mandatory fields.

Log in


Sign up | Forgot your password?

  • Staff Microsoft shows off IE9 preview

    This week, highlights from Microsoft's MIX10 conference and more in the Roundup. Read more »

    -- posted by Staff

  • Chris Duckett IE9's H.264 vote killed Ogg

    In a split decision by the judges, the winner of the W3C/WHATWG video codec consensus is H.264, taking home the future of video playback on the internet while loser Ogg goes home with nothing but thoughts of what might have been. Read more »

    -- posted by Chris Duckett

  • Staff Google launches Apps Marketplace

    Google launches and app store, while Mozilla plans to re-write its open-source license. More of this week's news in the Roundup. Read more »

    -- posted by Staff

What's on?

  • Optus Deal

    Broadband + home phone + PlayStation®3 in a single package price!