SVN Commit Hooks / Subversion Tags on IgorExchange

In email exchanges on the Igor listserver ...

Fernado wrote:

Hi all,

I know this is fairly off-topic (it has more to do with Igor Exchange than
with Igor itself), but I am quite confident that it will interest more than
one on the list.

Could somebody post the pre/post commit hooks they use in Subversion? I
would like to add/modify the first couple of lines in my versioned
procedures, and seeing that some packages on Igor Exchange already do this,
I thought I would just ask here before diving into the Subversion book.

Thank you in advance,

Adam wrote:

On IgorExchange, we use a pretty complicated set of pre and post
commit hook scripts to do several things:

1. Reject the commit if the log message is empty.
2. Send an email to me with information about every commit so that I
can monitor things and find problems earlier.
3. Enforce access control, making sure that the user has the
permission to commit code to the project it's being committed to.
4. Enforce branch and tag naming conventions so that releases work properly.

The hook scripts used on the site are quite complicated and written in
PHP. However there are sample scripts, written in Python, provided by
the Subversion authors that do #1 and #2 above. They are at
. Scroll down to the
pre-commit and post-commit sections.

If what you are looking for is to have things like the revision
number, date, committer username, etc. inserted in text files that are
committed (usually at the top of the file), you don't need hook
scripts. Instead, you just need to use Subversion properties. See

for general information about properties and how to set them with
subversion. The property you need is the svn:keywords property. See

for specific information on that keyword. Note that you have to both
set the svn:keyword property on the file and also include the keyword
anchor text in the file itself.

One caveat with doing this--when Igor opens text files, such as
procedure files, for editing it locks them. This means that you won't
be able to commit changes to any file that has the svn:keywords
property set and which includes the anchor text, because as Subversion
tries to commit the file it must modify it, and Igor's lock will
prevent that from happening.
I have a beginning outline of how to set the configuration file for properties and to work all this using svnX on the MacOS in case anyone is interested. I can also post my SVN config that is used to apply the author, date, revision, ... keywords somewhere on IgorExchange. Perhaps Adam can suggest the best location for this. I also have an example header that I use to set all these properties in a procedure file as well as an example coding I use to return the revision number in a GetInfo type dialog. I'll post these under the Code Snippets.

Note, unlike TortiseSVN (IMO an amazing tool on the Windows system), no free GUI type tool exists on the Mac to set/enforce SVN properties on a file. I have had to use svnX to store a default configuration and then apply it to each new file. Tedious to say the least.

I have never run across the file locking issue. Perhaps either because I am not using the anchor keyword and/or because I only commit on files not in use or in modification by Igor and/or because I do not quite understand what the issue is when it does happen (SVN is still a learning curve process for me).

J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH