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 Aussies to pay more for Win 7

    If you are looking to make some money in these troubled times, perhaps importing copies of Windows 7 could be for you. Read more »

    -- posted by Staff

  • Staff Firefox: Greens want it, 3.5rc2 not up to par

    This week's roundup looks at the situation surrounding a campaign to change Outlook HTML renderer, a Greens MP wants to install Firefox but is restricted and all the photos from the iPhone 3GS launch. Read more »

    -- posted by Staff

  • Chris Duckett Microsoft misses the Outlook point

    Ask designers which mail program is the bane of their existence, and you'll find that Outlook tops the list. The reason why the most popular email reader is also the most painful is simple: it uses Word to render HTML emails. Read more »

    -- posted by Chris Duckett

What's on?