Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81606 - in trunk/tools/server: . subversion subversion/hooks
From: grafikrobot_at_[hidden]
Date: 2012-11-27 22:44:18


Author: grafik
Date: 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
New Revision: 81606
URL: http://svn.boost.org/trac/boost/changeset/81606

Log:
Archive subversion server sripts.
Added:
   trunk/tools/server/
   trunk/tools/server/subversion/
   trunk/tools/server/subversion/hooks/
   trunk/tools/server/subversion/hooks/authorize.grep.disabled (contents, props changed)
   trunk/tools/server/subversion/hooks/case-insensitive.py (contents, props changed)
   trunk/tools/server/subversion/hooks/check-mime-type.pl (contents, props changed)
   trunk/tools/server/subversion/hooks/post-commit (contents, props changed)
   trunk/tools/server/subversion/hooks/post-commit.tmpl (contents, props changed)
   trunk/tools/server/subversion/hooks/post-lock.tmpl (contents, props changed)
   trunk/tools/server/subversion/hooks/post-revprop-change.tmpl (contents, props changed)
   trunk/tools/server/subversion/hooks/post-unlock.tmpl (contents, props changed)
   trunk/tools/server/subversion/hooks/pre-commit (contents, props changed)
   trunk/tools/server/subversion/hooks/pre-commit.bak (contents, props changed)
   trunk/tools/server/subversion/hooks/pre-commit.release (contents, props changed)
   trunk/tools/server/subversion/hooks/pre-commit.tmpl (contents, props changed)
   trunk/tools/server/subversion/hooks/pre-lock.tmpl (contents, props changed)
   trunk/tools/server/subversion/hooks/pre-revprop-change (contents, props changed)
   trunk/tools/server/subversion/hooks/pre-revprop-change.tmpl (contents, props changed)
   trunk/tools/server/subversion/hooks/pre-unlock.tmpl (contents, props changed)
   trunk/tools/server/subversion/hooks/start-commit.tmpl (contents, props changed)
   trunk/tools/server/subversion/hooks/test-post-commit (contents, props changed)
   trunk/tools/server/subversion/hooks/trac-post-commit-hook (contents, props changed)
   trunk/tools/server/subversion/hooks/trac-post-commit-hook.old (contents, props changed)
   trunk/tools/server/subversion/hooks/xml-check.sh (contents, props changed)

Added: trunk/tools/server/subversion/hooks/authorize.grep.disabled
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/authorize.grep.disabled 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,2 @@
+^....sandbox/authorize-test/
+^....branches/release/

Added: trunk/tools/server/subversion/hooks/case-insensitive.py
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/case-insensitive.py 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,145 @@
+#!/usr/bin/python24
+
+# A pre-commit hook to detect case-insensitive filename clashes.
+#
+# What this script does:
+# - Detects new paths that 'clash' with existing, or other new, paths.
+# - Ignores existings paths that already 'clash'
+# - Exits with an error code, and a diagnostic on stderr, if 'clashes'
+# are detected.
+# - DPG: Checks that there are no file names > 31 characters
+#
+# How it does it:
+# - Get a list of changed paths.
+# - From that list extract the new paths that represent adds or replaces.
+# - For each new path:
+# - Split the path into a directory and a name.
+# - Get the names of all the entries in the version of the directory
+# within the txn.
+# - Compare the canonical new name with each canonical entry name.
+# - If the canonical names match and the pristine names do not match
+# then we have a 'clash'.
+#
+# Notes:
+# - All the paths from the Subversion filesystem bindings are encoded
+# in UTF-8 and the separator is '/' on all OS's.
+# - The canonical form determines what constitutes a 'clash', at present
+# a simple 'lower case' is used. That's probably not identical to the
+# behaviour of Windows or OSX, but it might be good enough.
+# - Hooks get invoked with an empty environment so this script explicitly
+# sets a locale; make sure it is a sensible value.
+# - If used with Apache the 'clash' diagnostic must be ASCII irrespective
+# of the locale, see the 'Force' comment near the end of the script for
+# one way to achieve this.
+#
+# How to call it:
+#
+# On a Unix system put this script in the hooks directory and add this to
+# the pre-commit script:
+#
+# $REPOS/hooks/case-insensitive.py "$REPOS" "$TXN" || exit 1
+#
+# On a windows machine add this to pre-commit.bat:
+#
+# python <path-to-script>\case-insensitive.py %1 %2
+# if errorlevel 1 goto :ERROR
+# exit 0
+# :ERROR
+# echo Error found in commit 1>&2
+# exit 1
+#
+# Make sure the python bindings are installed and working on Windows. The
+# zip file can be downloaded from the Subversion site. The bindings depend
+# on dll's shipped as part of the Subversion binaries, if the script cannot
+# load the _fs dll it is because it cannot find the other Subversion dll's.
+#
+# $HeadURL$
+# $LastChangedRevision$
+# $LastChangedDate$
+# $LastChangedBy$
+
+import sys, locale
+sys.path.append('/usr/local/subversion/lib/svn-python')
+from svn import repos, fs
+locale.setlocale(locale.LC_ALL, 'en_GB')
+
+def canonicalize(path):
+ return path.decode('utf-8').lower().encode('utf-8')
+
+def get_new_paths(txn_root):
+ new_paths = []
+ for path, change in fs.paths_changed(txn_root).iteritems():
+ if (change.change_kind == fs.path_change_add
+ or change.change_kind == fs.path_change_replace):
+ new_paths.append(path)
+ return new_paths
+
+def split_path(path):
+ slash = path.rindex('/')
+ if (slash == 0):
+ return '/', path[1:]
+ return path[:slash], path[slash+1:]
+
+def join_path(dir, name):
+ if (dir == '/'):
+ return '/' + name
+ return dir + '/' + name
+
+def ensure_names(path, names, txn_root):
+ if (not names.has_key(path)):
+ names[path] = []
+ for name, dirent in fs.dir_entries(txn_root, path).iteritems():
+ names[path].append([canonicalize(name), name])
+
+names = {} # map of: key - path, value - list of two element lists of names
+clashes = {} # map of: key - path, value - map of: key - path, value - dummy
+
+native = locale.getlocale()[1]
+if not native: native = 'ascii'
+repos_handle = repos.open(sys.argv[1].decode(native).encode('utf-8'))
+fs_handle = repos.fs(repos_handle)
+txn_handle = fs.open_txn(fs_handle, sys.argv[2].decode(native).encode('utf-8'))
+txn_root = fs.txn_root(txn_handle)
+
+new_paths = get_new_paths(txn_root)
+for path in new_paths:
+ dir, name = split_path(path)
+ canonical = canonicalize(name)
+ ensure_names(dir, names, txn_root)
+ for name_pair in names[dir]:
+ if (name_pair[0] == canonical and name_pair[1] != name):
+ canonical_path = join_path(dir, canonical)
+ if (not clashes.has_key(canonical_path)):
+ clashes[canonical_path] = {}
+ clashes[canonical_path][join_path(dir, name)] = True
+ clashes[canonical_path][join_path(dir, name_pair[1])] = True
+
+if (clashes):
+ # native = 'ascii' # Force ASCII output for Apache
+ for canonical_path in clashes.iterkeys():
+ sys.stderr.write(u'Clash:'.encode(native))
+ for path in clashes[canonical_path].iterkeys():
+ sys.stderr.write(u' \''.encode(native) +
+ str(path).decode('utf-8').encode(native, 'replace') +
+ u'\''.encode(native))
+ sys.stderr.write(u'\n'.encode(native))
+ sys.exit(1)
+
+# Check for filenames > 31 characters long
+# [disable this test until name length limit dispute is resolved]
+# new_paths = get_new_paths(txn_root)
+new_paths = []
+# [-]
+any_names_too_long = False
+for path in new_paths:
+ dir, name = split_path(path)
+ if len(name) > 31:
+ if not any_names_too_long:
+ sys.stderr.write(u'File names with > 31 characters:\n'.encode(native))
+ any_names_too_long = True
+ sys.stderr.write(u' '.encode(native) +
+ str(path).decode('utf-8').encode(native, 'replace'))
+ sys.stderr.write(u'\n'.encode(native))
+
+if any_names_too_long:
+ sys.exit(1)

Added: trunk/tools/server/subversion/hooks/check-mime-type.pl
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/check-mime-type.pl 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,250 @@
+#!/usr/local/bin/perl
+
+# ====================================================================
+# commit-mime-type-check.pl: check that every added file has the
+# svn:mime-type property set and every added file with a mime-type
+# matching text/* also has svn:eol-style set. If any file fails this
+# test the user is sent a verbose error message suggesting solutions and
+# the commit is aborted.
+#
+# Usage: commit-mime-type-check.pl REPOS TXN-NAME
+# ====================================================================
+# Most of commit-mime-type-check.pl was taken from
+# commit-access-control.pl, Revision 9986, 2004-06-14 16:29:22 -0400.
+# ====================================================================
+# Copyright (c) 2000-2004 CollabNet. All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://subversion.tigris.org/license.html.
+# If newer versions of this license are posted there, you may use a
+# newer version instead, at your option.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For exact contribution history, see the revision
+# history and logs, available at http://subversion.tigris.org/.
+# ====================================================================
+
+# Turn on warnings the best way depending on the Perl version.
+BEGIN {
+ if ( $] >= 5.006_000)
+ { require warnings; import warnings; }
+ else
+ { $^W = 1; }
+}
+
+use strict;
+use Carp;
+
+
+######################################################################
+# Configuration section.
+
+# Svnlook path.
+my $svnlook = "/usr/bin/svnlook";
+
+# Since the path to svnlook depends upon the local installation
+# preferences, check that the required program exists to insure that
+# the administrator has set up the script properly.
+{
+ my $ok = 1;
+ foreach my $program ($svnlook)
+ {
+ if (-e $program)
+ {
+ unless (-x $program)
+ {
+ warn "$0: required program `$program' is not executable, ",
+ "edit $0.\n";
+ $ok = 0;
+ }
+ }
+ else
+ {
+ warn "$0: required program `$program' does not exist, edit $0.\n";
+ $ok = 0;
+ }
+ }
+ exit 1 unless $ok;
+}
+
+######################################################################
+# Initial setup/command-line handling.
+
+&usage unless @ARGV == 2;
+
+my $repos = shift;
+my $txn = shift;
+
+unless (-e $repos)
+ {
+ &usage("$0: repository directory `$repos' does not exist.");
+ }
+unless (-d $repos)
+ {
+ &usage("$0: repository directory `$repos' is not a directory.");
+ }
+
+# Define two constant subroutines to stand for read-only or read-write
+# access to the repository.
+sub ACCESS_READ_ONLY () { 'read-only' }
+sub ACCESS_READ_WRITE () { 'read-write' }
+
+
+######################################################################
+# Harvest data using svnlook.
+
+# Change into /tmp so that svnlook diff can create its .svnlook
+# directory.
+my $tmp_dir = '/tmp';
+chdir($tmp_dir)
+ or die "$0: cannot chdir `$tmp_dir': $!\n";
+
+# Figure out what files have added using svnlook.
+my @files_added;
+foreach my $line (&read_from_process($svnlook, 'changed', $repos, '-t', $txn))
+ {
+ # Add only files that were added to @files_added
+ if ($line =~ /^A. (.*[^\/])$/)
+ {
+ push(@files_added, $1);
+ }
+ }
+
+my @errors;
+foreach my $path ( @files_added )
+ {
+ my $mime_type;
+ my $eol_style;
+
+ # Parse the complete list of property values of the file $path to extract
+ # the mime-type and eol-style
+ foreach my $prop (&read_from_process($svnlook, 'proplist', $repos, '-t',
+ $txn, '--verbose', $path))
+ {
+ if ($prop =~ /^\s*svn:mime-type : (\S+)/)
+ {
+ $mime_type = $1;
+ }
+ elsif ($prop =~ /^\s*svn:eol-style : (\S+)/)
+ {
+ $eol_style = $1;
+ }
+ }
+
+ # Detect error conditions and add them to @errors
+ if (not $mime_type)
+ {
+ push @errors, "$path : svn:mime-type is not set";
+ }
+ elsif ($mime_type =~ /^text\// and not $eol_style)
+ {
+ push @errors, "$path : svn:mime-type=$mime_type but svn:eol-style is not set";
+ }
+ }
+
+# If there are any errors list the problem files and give information
+# on how to avoid the problem. Hopefully people will set up auto-props
+# and will not see this verbose message more than once.
+if (@errors)
+ {
+ warn "$0:\n\n",
+ join("\n", @errors), "\n\n",
+ <<EOS;
+
+ Every added file must have the svn:mime-type property set. In
+ addition text files must have the svn:eol-style property set.
+
+ For binary files try running
+ svn propset svn:mime-type application/octet-stream path/of/file
+
+ For text files try
+ svn propset svn:mime-type text/plain path/of/file
+ svn propset svn:eol-style native path/of/file
+
+ You may want to consider uncommenting the auto-props section
+ in your ~/.subversion/config file. Read the Subversion book
+ (http://svnbook.red-bean.com/), Chapter 7, Properties section,
+ Automatic Property Setting subsection for more help. Also,
+ see http://svn.boost.org/trac/boost/wiki/BoostSubversion
+EOS
+ exit 1;
+ }
+else
+ {
+ exit 0;
+ }
+
+sub usage
+{
+ warn "@_\n" if @_;
+ die "usage: $0 REPOS TXN-NAME\n";
+}
+
+sub safe_read_from_pipe
+{
+ unless (@_)
+ {
+ croak "$0: safe_read_from_pipe passed no arguments.\n";
+ }
+ print "Running @_\n";
+ my $pid = open(SAFE_READ, '-|');
+ unless (defined $pid)
+ {
+ die "$0: cannot fork: $!\n";
+ }
+ unless ($pid)
+ {
+ open(STDERR, ">&STDOUT")
+ or die "$0: cannot dup STDOUT: $!\n";
+ exec(@_)
+ or die "$0: cannot exec `@_': $!\n";
+ }
+ my @output;
+ while (<SAFE_READ>)
+ {
+ chomp;
+ push(@output, $_);
+ }
+ close(SAFE_READ);
+ my $result = $?;
+ my $exit = $result >> 8;
+ my $signal = $result & 127;
+ my $cd = $result & 128 ? "with core dump" : "";
+ if ($signal or $cd)
+ {
+ warn "$0: pipe from `@_' failed $cd: exit=$exit signal=$signal\n";
+ }
+ if (wantarray)
+ {
+ return ($result, @output);
+ }
+ else
+ {
+ return $result;
+ }
+}
+
+sub read_from_process
+ {
+ unless (@_)
+ {
+ croak "$0: read_from_process passed no arguments.\n";
+ }
+ my ($status, @output) = &safe_read_from_pipe(@_);
+ if ($status)
+ {
+ if (@output)
+ {
+ die "$0: `@_' failed with this output:\n", join("\n", @output), "\n";
+ }
+ else
+ {
+ die "$0: `@_' failed with no output.\n";
+ }
+ }
+ else
+ {
+ return @output;
+ }
+}

Added: trunk/tools/server/subversion/hooks/post-commit
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/post-commit 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+# POST-COMMIT HOOK
+#
+# The post-commit hook is invoked after a commit. Subversion runs
+# this hook by invoking a program (script, executable, binary,
+# etc.) named 'post-commit' (for which
+# this file is a template) with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] REV (the number of the revision just committed)
+#
+# Because the commit has already completed and cannot be undone,
+# the exit code of the hook program is ignored. The hook program
+# can use the 'svnlook' utility to help it examine the
+# newly-committed tree.
+#
+# On a Unix system, the normal procedure is to have 'post-commit'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'post-commit' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'post-commit.bat' or 'post-commit.exe',
+# but the basic idea is the same.
+#
+
+REPOS="$1"
+REV="$2"
+
+/bin/touch /home/dikim/temp/babo
+
+#
+# New Mailer script hooks
+#
+export PYTHON_EGG_CACHE="/home/svn_cache"
+MAILER_SCRIPT=/opt/subversion/mailer_boost.py
+SVNDIR=/home/subversion/boost
+${MAILER_SCRIPT} commit "$REPOS" "$REV" ${SVNDIR}/conf/mailer.conf
+
+/bin/touch /home/dikim/temp/boba
+
+LOG=`/usr/bin/svnlook log -r $REV $REPOS`
+AUTHOR=`/usr/bin/svnlook author -r $REV $REPOS`
+TRAC_ENV='/opt/trac/boost/'
+TRAC_URL='http://svn.boost.org/trac/boost/'
+#export PYTHONPATH="/opt/trac/lib/python2.3/site-packages/Trac-0.11-py2.3.egg/"
+#export PYTHONPATH="/opt/trac2/lib/python2.4/site-packages/Trac-0.11.5-py2.4.egg/"
+export PYTHONPATH="/opt/python-2.6/lib/python2.6/site-packages/Trac-0.12-py2.6.egg"
+
+/opt/python-2.6/bin/python /home/subversion/boost/hooks/trac-post-commit-hook \
+ -p "$TRAC_ENV" \
+ -r "$REV" \
+ -u "$AUTHOR" \
+ -m "$LOG" \
+ -s "$TRAC_URL"
+
+#
+# Update boost website
+#
+WEBDIR=/home/www/beta.boost.org
+cd $WEBDIR
+svn up
+cd /home/www/live.boost.org
+svn up

Added: trunk/tools/server/subversion/hooks/post-commit.tmpl
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/post-commit.tmpl 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# POST-COMMIT HOOK
+#
+# The post-commit hook is invoked after a commit. Subversion runs
+# this hook by invoking a program (script, executable, binary, etc.)
+# named 'post-commit' (for which this file is a template) with the
+# following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] REV (the number of the revision just committed)
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# Because the commit has already completed and cannot be undone,
+# the exit code of the hook program is ignored. The hook program
+# can use the 'svnlook' utility to help it examine the
+# newly-committed tree.
+#
+# On a Unix system, the normal procedure is to have 'post-commit'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'post-commit' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'post-commit.bat' or 'post-commit.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+REV="$2"
+
+mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf

Added: trunk/tools/server/subversion/hooks/post-lock.tmpl
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/post-lock.tmpl 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# POST-LOCK HOOK
+#
+# The post-lock hook is run after a path is locked. Subversion runs
+# this hook by invoking a program (script, executable, binary, etc.)
+# named 'post-lock' (for which this file is a template) with the
+# following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] USER (the user who created the lock)
+#
+# The paths that were just locked are passed to the hook via STDIN (as
+# of Subversion 1.2, only one path is passed per invocation, but the
+# plan is to pass all locked paths at once, so the hook program
+# should be written accordingly).
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# Because the lock has already been created and cannot be undone,
+# the exit code of the hook program is ignored. The hook program
+# can use the 'svnlook' utility to help it examine the
+# newly-created lock.
+#
+# On a Unix system, the normal procedure is to have 'post-lock'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'post-lock' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'post-lock.bat' or 'post-lock.exe',
+# but the basic idea is the same.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter:
+
+REPOS="$1"
+USER="$2"
+
+# Send email to interested parties, let them know a lock was created:
+mailer.py lock "$REPOS" "$USER" /path/to/mailer.conf

Added: trunk/tools/server/subversion/hooks/post-revprop-change.tmpl
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/post-revprop-change.tmpl 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+# POST-REVPROP-CHANGE HOOK
+#
+# The post-revprop-change hook is invoked after a revision property
+# has been added, modified or deleted. Subversion runs this hook by
+# invoking a program (script, executable, binary, etc.) named
+# 'post-revprop-change' (for which this file is a template), with the
+# following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] REV (the revision that was tweaked)
+# [3] USER (the username of the person tweaking the property)
+# [4] PROPNAME (the property that was changed)
+# [5] ACTION (the property was 'A'dded, 'M'odified, or 'D'eleted)
+#
+# [STDIN] PROPVAL ** the old property value is passed via STDIN.
+#
+# Because the propchange has already completed and cannot be undone,
+# the exit code of the hook program is ignored. The hook program
+# can use the 'svnlook' utility to help it examine the
+# new property value.
+#
+# On a Unix system, the normal procedure is to have 'post-revprop-change'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'post-revprop-change' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'post-revprop-change.bat' or 'post-revprop-change.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+REV="$2"
+USER="$3"
+PROPNAME="$4"
+ACTION="$5"
+
+mailer.py propchange2 "$REPOS" "$REV" "$USER" "$PROPNAME" "$ACTION" /path/to/mailer.conf

Added: trunk/tools/server/subversion/hooks/post-unlock.tmpl
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/post-unlock.tmpl 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# POST-UNLOCK HOOK
+#
+# The post-unlock hook runs after a path is unlocked. Subversion runs
+# this hook by invoking a program (script, executable, binary, etc.)
+# named 'post-unlock' (for which this file is a template) with the
+# following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] USER (the user who destroyed the lock)
+#
+# The paths that were just unlocked are passed to the hook via STDIN
+# (as of Subversion 1.2, only one path is passed per invocation, but
+# the plan is to pass all unlocked paths at once, so the hook program
+# should be written accordingly).
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# Because the lock has already been destroyed and cannot be undone,
+# the exit code of the hook program is ignored.
+#
+# On a Unix system, the normal procedure is to have 'post-unlock'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'post-unlock' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'post-unlock.bat' or 'post-unlock.exe',
+# but the basic idea is the same.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter:
+
+REPOS="$1"
+USER="$2"
+
+# Send email to interested parties, let them know a lock was removed:
+mailer.py unlock "$REPOS" "$USER" /path/to/mailer.conf

Added: trunk/tools/server/subversion/hooks/pre-commit
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/pre-commit 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,103 @@
+#!/bin/bash
+
+# PRE-COMMIT HOOK
+#
+# The pre-commit hook is invoked before a Subversion txn is
+# committed. Subversion runs this hook by invoking a program
+# (script, executable, binary, etc.) named 'pre-commit' (for which
+# this file is a template), with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] TXN-NAME (the name of the txn about to be committed)
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# If the hook program exits with success, the txn is committed; but
+# if it exits with failure (non-zero), the txn is aborted, no commit
+# takes place, and STDERR is returned to the client. The hook
+# program can use the 'svnlook' utility to help it examine the txn.
+#
+# On a Unix system, the normal procedure is to have 'pre-commit'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# *** NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT ***
+# *** FOR REVISION PROPERTIES (like svn:log or svn:author). ***
+#
+# This is why we recommend using the read-only 'svnlook' utility.
+# In the future, Subversion may enforce the rule that pre-commit
+# hooks should not modify the versioned data in txns, or else come
+# up with a mechanism to make it safe to do so (by informing the
+# committing client of the changes). However, right now neither
+# mechanism is implemented, so hook writers just have to be careful.
+#
+# Note that 'pre-commit' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-commit.bat' or 'pre-commit.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+#REPOS="$1"
+REPOS="/home/subversion/boost"
+TXN="$2"
+
+# Make sure that the log message contains some text.
+SVNLOOK=/usr/bin/svnlook
+$SVNLOOK log -t "$TXN" "$REPOS" | \
+ grep "[a-zA-Z0-9]" > /dev/null || exit 1
+
+/bin/touch /home/dikim/temp/pre-babo
+
+# Check for problems with case-insensitive names
+/usr/bin/python24 /home/subversion/boost/hooks/case-insensitive.py "$REPOS" "$TXN" || exit 1
+
+# Check svn:mime-type and svn:eol-style
+/usr/local/bin/perl /home/subversion/boost/hooks/check-mime-type.pl \
+ "$REPOS" "$TXN" || exit 1
+
+# Check for an empty log message
+RES=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]"`
+
+if [ "$RES" = "" ]; then
+ echo "Won't commit with an empty log message." 2>&1
+ $SVNLOOK changed -t "$TXN" $REPOS 1>&2
+ exit 1
+fi
+
+# Check for authorized commits on release lock-down
+if [ -r "$REPOS/authorize.grep" ] ; then
+ RES=`$SVNLOOK changed -t "$TXN" "$REPOS" | grep -cE -f "$REPOS/authorize.grep"`
+ if [ "$RES" != "0" ] ; then
+ RES=`$SVNLOOK log -t "$TXN" "$REPOS" | grep -ioE "authorized[[:space:]]+by[[:space:]]+[[:alnum:]]+"`
+ if [ "$RES" = "" ]; then
+ echo "Changes to this location requires authorization from the release team:" 2>&1
+ $SVNLOOK changed -t "$TXN" "$REPOS" | grep -E -f "$REPOS/authorize.grep" 1>&2
+ exit 1
+ fi
+ fi
+fi
+
+/bin/touch /home/dikim/temp/pre-boba
+
+# Check validity of XML files
+# /bin/bash /home/subversion/boost/hooks/xml-check.sh "$REPOS" "$TXN" || exit 1
+
+# All checks passed, so allow the commit.
+exit 0

Added: trunk/tools/server/subversion/hooks/pre-commit.bak
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/pre-commit.bak 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,90 @@
+#!/bin/bash
+
+# PRE-COMMIT HOOK
+#
+# The pre-commit hook is invoked before a Subversion txn is
+# committed. Subversion runs this hook by invoking a program
+# (script, executable, binary, etc.) named 'pre-commit' (for which
+# this file is a template), with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] TXN-NAME (the name of the txn about to be committed)
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# If the hook program exits with success, the txn is committed; but
+# if it exits with failure (non-zero), the txn is aborted, no commit
+# takes place, and STDERR is returned to the client. The hook
+# program can use the 'svnlook' utility to help it examine the txn.
+#
+# On a Unix system, the normal procedure is to have 'pre-commit'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# *** NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT ***
+# *** FOR REVISION PROPERTIES (like svn:log or svn:author). ***
+#
+# This is why we recommend using the read-only 'svnlook' utility.
+# In the future, Subversion may enforce the rule that pre-commit
+# hooks should not modify the versioned data in txns, or else come
+# up with a mechanism to make it safe to do so (by informing the
+# committing client of the changes). However, right now neither
+# mechanism is implemented, so hook writers just have to be careful.
+#
+# Note that 'pre-commit' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-commit.bat' or 'pre-commit.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+#REPOS="$1"
+REPOS="/home/subversion/boost"
+TXN="$2"
+
+# Make sure that the log message contains some text.
+SVNLOOK=/usr/bin/svnlook
+$SVNLOOK log -t "$TXN" "$REPOS" | \
+ grep "[a-zA-Z0-9]" > /dev/null || exit 1
+
+/bin/touch /home/dikim/temp/pre-babo
+
+# Check for problems with case-insensitive names
+/usr/bin/python24 /home/subversion/boost/hooks/case-insensitive.py "$REPOS" "$TXN" || exit 1
+
+# Check svn:mime-type and svn:eol-style
+/usr/local/bin/perl /home/subversion/boost/hooks/check-mime-type.pl \
+ "$REPOS" "$TXN" || exit 1
+
+# Check for an empty log message
+RES=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]"`
+
+if [ "$RES" = "" ]; then
+ echo "Won't commit with an empty log message." 2>&1
+ $SVNLOOK changed -t "$TXN" $REPOS 1>&2
+ exit 1
+fi
+
+/bin/touch /home/dikim/temp/pre-boba
+
+# Check validity of XML files
+# /bin/bash /home/subversion/boost/hooks/xml-check.sh "$REPOS" "$TXN" || exit 1
+
+# All checks passed, so allow the commit.
+exit 0

Added: trunk/tools/server/subversion/hooks/pre-commit.release
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/pre-commit.release 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,103 @@
+#!/bin/bash
+
+# PRE-COMMIT HOOK
+#
+# The pre-commit hook is invoked before a Subversion txn is
+# committed. Subversion runs this hook by invoking a program
+# (script, executable, binary, etc.) named 'pre-commit' (for which
+# this file is a template), with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] TXN-NAME (the name of the txn about to be committed)
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# If the hook program exits with success, the txn is committed; but
+# if it exits with failure (non-zero), the txn is aborted, no commit
+# takes place, and STDERR is returned to the client. The hook
+# program can use the 'svnlook' utility to help it examine the txn.
+#
+# On a Unix system, the normal procedure is to have 'pre-commit'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# *** NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT ***
+# *** FOR REVISION PROPERTIES (like svn:log or svn:author). ***
+#
+# This is why we recommend using the read-only 'svnlook' utility.
+# In the future, Subversion may enforce the rule that pre-commit
+# hooks should not modify the versioned data in txns, or else come
+# up with a mechanism to make it safe to do so (by informing the
+# committing client of the changes). However, right now neither
+# mechanism is implemented, so hook writers just have to be careful.
+#
+# Note that 'pre-commit' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-commit.bat' or 'pre-commit.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+#REPOS="$1"
+REPOS="/home/subversion/boost"
+TXN="$2"
+
+# Make sure that the log message contains some text.
+SVNLOOK=/usr/bin/svnlook
+$SVNLOOK log -t "$TXN" "$REPOS" | \
+ grep "[a-zA-Z0-9]" > /dev/null || exit 1
+
+/bin/touch /home/dikim/temp/pre-babo
+
+# Check for problems with case-insensitive names
+/usr/bin/python24 /home/subversion/boost/hooks/case-insensitive.py "$REPOS" "$TXN" || exit 1
+
+# Check svn:mime-type and svn:eol-style
+/usr/local/bin/perl /home/subversion/boost/hooks/check-mime-type.pl \
+ "$REPOS" "$TXN" || exit 1
+
+# Check for an empty log message
+RES=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]"`
+
+if [ "$RES" = "" ]; then
+ echo "Won't commit with an empty log message." 2>&1
+ $SVNLOOK changed -t "$TXN" $REPOS 1>&2
+ exit 1
+fi
+
+# Check for authorized commits on release lock-down
+if [ -r "$REPOS/authorize.grep" ] ; then
+ RES=`$SVNLOOK changed -t "$TXN" "$REPOS" | grep -cE -f "$REPOS/authorize.grep"`
+ if [ "$RES" != "0" ] ; then
+ RES=`$SVNLOOK log -t "$TXN" "$REPOS" | grep -ioE "authorized[[:space:]]+by[[:space:]]+[[:alnum:]]+"`
+ if [ "$RES" = "" ]; then
+ echo "Changes to this location requires authorization from the release team:" 2>&1
+ $SVNLOOK changed -t "$TXN" "$REPOS" | grep -E -f "$REPOS/authorize.grep" 1>&2
+ exit 1
+ fi
+ fi
+fi
+
+/bin/touch /home/dikim/temp/pre-boba
+
+# Check validity of XML files
+# /bin/bash /home/subversion/boost/hooks/xml-check.sh "$REPOS" "$TXN" || exit 1
+
+# All checks passed, so allow the commit.
+exit 0

Added: trunk/tools/server/subversion/hooks/pre-commit.tmpl
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/pre-commit.tmpl 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+# PRE-COMMIT HOOK
+#
+# The pre-commit hook is invoked before a Subversion txn is
+# committed. Subversion runs this hook by invoking a program
+# (script, executable, binary, etc.) named 'pre-commit' (for which
+# this file is a template), with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] TXN-NAME (the name of the txn about to be committed)
+#
+# [STDIN] LOCK-TOKENS ** the lock tokens are passed via STDIN.
+#
+# If STDIN contains the line "LOCK-TOKENS:\n" (the "\n" denotes a
+# single newline), the lines following it are the lock tokens for
+# this commit. The end of the list is marked by a line containing
+# only a newline character.
+#
+# Each lock token line consists of a URI-escaped path, followed
+# by the separator character '|', followed by the lock token string,
+# followed by a newline.
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# If the hook program exits with success, the txn is committed; but
+# if it exits with failure (non-zero), the txn is aborted, no commit
+# takes place, and STDERR is returned to the client. The hook
+# program can use the 'svnlook' utility to help it examine the txn.
+#
+# On a Unix system, the normal procedure is to have 'pre-commit'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# *** NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT ***
+# *** FOR REVISION PROPERTIES (like svn:log or svn:author). ***
+#
+# This is why we recommend using the read-only 'svnlook' utility.
+# In the future, Subversion may enforce the rule that pre-commit
+# hooks should not modify the versioned data in txns, or else come
+# up with a mechanism to make it safe to do so (by informing the
+# committing client of the changes). However, right now neither
+# mechanism is implemented, so hook writers just have to be careful.
+#
+# Note that 'pre-commit' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-commit.bat' or 'pre-commit.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+TXN="$2"
+
+# Make sure that the log message contains some text.
+SVNLOOK=/usr/bin/svnlook
+$SVNLOOK log -t "$TXN" "$REPOS" | \
+ grep "[a-zA-Z0-9]" > /dev/null || exit 1
+
+# Check that the author of this commit has the rights to perform
+# the commit on the files and directories being modified.
+commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1
+
+# All checks passed, so allow the commit.
+exit 0

Added: trunk/tools/server/subversion/hooks/pre-lock.tmpl
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/pre-lock.tmpl 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+# PRE-LOCK HOOK
+#
+# The pre-lock hook is invoked before an exclusive lock is
+# created. Subversion runs this hook by invoking a program
+# (script, executable, binary, etc.) named 'pre-lock' (for which
+# this file is a template), with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] PATH (the path in the repository about to be locked)
+# [3] USER (the user creating the lock)
+# [4] COMMENT (the comment of the lock)
+# [5] STEAL-LOCK (1 if the user is trying to steal the lock, else 0)
+#
+# If the hook program outputs anything on stdout, the output string will
+# be used as the lock token for this lock operation. If you choose to use
+# this feature, you must guarantee the tokens generated are unique across
+# the repository each time.
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# If the hook program exits with success, the lock is created; but
+# if it exits with failure (non-zero), the lock action is aborted
+# and STDERR is returned to the client.
+
+# On a Unix system, the normal procedure is to have 'pre-lock'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'pre-lock' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-lock.bat' or 'pre-lock.exe',
+# but the basic idea is the same.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter:
+
+REPOS="$1"
+PATH="$2"
+USER="$3"
+
+# If a lock exists and is owned by a different person, don't allow it
+# to be stolen (e.g., with 'svn lock --force ...').
+
+# (Maybe this script could send email to the lock owner?)
+SVNLOOK=/usr/bin/svnlook
+GREP=/bin/grep
+SED=/bin/sed
+
+LOCK_OWNER=`$SVNLOOK lock "$REPOS" "$PATH" | \
+ $GREP '^Owner: ' | $SED 's/Owner: //'`
+
+# If we get no result from svnlook, there's no lock, allow the lock to
+# happen:
+if [ "$LOCK_OWNER" = "" ]; then
+ exit 0
+fi
+
+# If the person locking matches the lock's owner, allow the lock to
+# happen:
+if [ "$LOCK_OWNER" = "$USER" ]; then
+ exit 0
+fi
+
+# Otherwise, we've got an owner mismatch, so return failure:
+echo "Error: $PATH already locked by ${LOCK_OWNER}." 1>&2
+exit 1

Added: trunk/tools/server/subversion/hooks/pre-revprop-change
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/pre-revprop-change 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# PRE-REVPROP-CHANGE HOOK
+#
+# The pre-revprop-change hook is invoked before a revision property
+# is added, modified or deleted. Subversion runs this hook by invoking
+# a program (script, executable, binary, etc.) named 'pre-revprop-change'
+# (for which this file is a template), with the following ordered
+# arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] REVISION (the revision being tweaked)
+# [3] USER (the username of the person tweaking the property)
+# [4] PROPNAME (the property being set on the revision)
+# [5] ACTION (the property is being 'A'dded, 'M'odified, or 'D'eleted)
+#
+# [STDIN] PROPVAL ** the new property value is passed via STDIN.
+#
+# If the hook program exits with success, the propchange happens; but
+# if it exits with failure (non-zero), the propchange doesn't happen.
+# The hook program can use the 'svnlook' utility to examine the
+# existing value of the revision property.
+#
+# WARNING: unlike other hooks, this hook MUST exist for revision
+# properties to be changed. If the hook does not exist, Subversion
+# will behave as if the hook were present, but failed. The reason
+# for this is that revision properties are UNVERSIONED, meaning that
+# a successful propchange is destructive; the old value is gone
+# forever. We recommend the hook back up the old value somewhere.
+#
+# On a Unix system, the normal procedure is to have 'pre-revprop-change'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'pre-revprop-change' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-revprop-change.bat' or 'pre-revprop-change.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+REV="$2"
+USER="$3"
+PROPNAME="$4"
+ACTION="$5"
+
+if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi
+
+echo "Changing revision properties other than svn:log is prohibited" >&2
+exit 1

Added: trunk/tools/server/subversion/hooks/pre-revprop-change.tmpl
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/pre-revprop-change.tmpl 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# PRE-REVPROP-CHANGE HOOK
+#
+# The pre-revprop-change hook is invoked before a revision property
+# is added, modified or deleted. Subversion runs this hook by invoking
+# a program (script, executable, binary, etc.) named 'pre-revprop-change'
+# (for which this file is a template), with the following ordered
+# arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] REVISION (the revision being tweaked)
+# [3] USER (the username of the person tweaking the property)
+# [4] PROPNAME (the property being set on the revision)
+# [5] ACTION (the property is being 'A'dded, 'M'odified, or 'D'eleted)
+#
+# [STDIN] PROPVAL ** the new property value is passed via STDIN.
+#
+# If the hook program exits with success, the propchange happens; but
+# if it exits with failure (non-zero), the propchange doesn't happen.
+# The hook program can use the 'svnlook' utility to examine the
+# existing value of the revision property.
+#
+# WARNING: unlike other hooks, this hook MUST exist for revision
+# properties to be changed. If the hook does not exist, Subversion
+# will behave as if the hook were present, but failed. The reason
+# for this is that revision properties are UNVERSIONED, meaning that
+# a successful propchange is destructive; the old value is gone
+# forever. We recommend the hook back up the old value somewhere.
+#
+# On a Unix system, the normal procedure is to have 'pre-revprop-change'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'pre-revprop-change' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-revprop-change.bat' or 'pre-revprop-change.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+REV="$2"
+USER="$3"
+PROPNAME="$4"
+ACTION="$5"
+
+if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi
+
+echo "Changing revision properties other than svn:log is prohibited" >&2
+exit 1

Added: trunk/tools/server/subversion/hooks/pre-unlock.tmpl
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/pre-unlock.tmpl 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+# PRE-UNLOCK HOOK
+#
+# The pre-unlock hook is invoked before an exclusive lock is
+# destroyed. Subversion runs this hook by invoking a program
+# (script, executable, binary, etc.) named 'pre-unlock' (for which
+# this file is a template), with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] PATH (the path in the repository about to be unlocked)
+# [3] USER (the user destroying the lock)
+# [4] TOKEN (the lock token to be destroyed)
+# [5] BREAK-UNLOCK (1 if the user is breaking the lock, else 0)
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# If the hook program exits with success, the lock is destroyed; but
+# if it exits with failure (non-zero), the unlock action is aborted
+# and STDERR is returned to the client.
+
+# On a Unix system, the normal procedure is to have 'pre-unlock'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'pre-unlock' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-unlock.bat' or 'pre-unlock.exe',
+# but the basic idea is the same.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter:
+
+REPOS="$1"
+PATH="$2"
+USER="$3"
+
+# If a lock is owned by a different person, don't allow it be broken.
+# (Maybe this script could send email to the lock owner?)
+
+SVNLOOK=/usr/bin/svnlook
+GREP=/bin/grep
+SED=/bin/sed
+
+LOCK_OWNER=`$SVNLOOK lock "$REPOS" "$PATH" | \
+ $GREP '^Owner: ' | $SED 's/Owner: //'`
+
+# If we get no result from svnlook, there's no lock, return success:
+if [ "$LOCK_OWNER" = "" ]; then
+ exit 0
+fi
+
+# If the person unlocking matches the lock's owner, return success:
+if [ "$LOCK_OWNER" = "$USER" ]; then
+ exit 0
+fi
+
+# Otherwise, we've got an owner mismatch, so return failure:
+echo "Error: $PATH locked by ${LOCK_OWNER}." 1>&2
+exit 1

Added: trunk/tools/server/subversion/hooks/start-commit.tmpl
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/start-commit.tmpl 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+# START-COMMIT HOOK
+#
+# The start-commit hook is invoked before a Subversion txn is created
+# in the process of doing a commit. Subversion runs this hook
+# by invoking a program (script, executable, binary, etc.) named
+# 'start-commit' (for which this file is a template)
+# with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] USER (the authenticated user attempting to commit)
+# [3] CAPABILITIES (a colon-separated list of capabilities reported
+# by the client; see note below)
+#
+# Note: The CAPABILITIES parameter is new in Subversion 1.5, and 1.5
+# clients will typically report at least the "mergeinfo" capability.
+# If there are other capabilities, then the list is colon-separated,
+# e.g.: "mergeinfo:some-other-capability" (the order is undefined).
+#
+# The list is self-reported by the client. Therefore, you should not
+# make security assumptions based on the capabilities list, nor should
+# you assume that clients reliably report every capability they have.
+#
+# The working directory for this hook program's invocation is undefined,
+# so the program should set one explicitly if it cares.
+#
+# If the hook program exits with success, the commit continues; but
+# if it exits with failure (non-zero), the commit is stopped before
+# a Subversion txn is created, and STDERR is returned to the client.
+#
+# On a Unix system, the normal procedure is to have 'start-commit'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'start-commit' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'start-commit.bat' or 'start-commit.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+USER="$2"
+
+commit-allower.pl --repository "$REPOS" --user "$USER" || exit 1
+special-auth-check.py --user "$USER" --auth-level 3 || exit 1
+
+# All checks passed, so allow the commit.
+exit 0

Added: trunk/tools/server/subversion/hooks/test-post-commit
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/test-post-commit 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+# POST-COMMIT HOOK
+#
+# The post-commit hook is invoked after a commit. Subversion runs
+# this hook by invoking a program (script, executable, binary,
+# etc.) named 'post-commit' (for which
+# this file is a template) with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] REV (the number of the revision just committed)
+#
+# Because the commit has already completed and cannot be undone,
+# the exit code of the hook program is ignored. The hook program
+# can use the 'svnlook' utility to help it examine the
+# newly-committed tree.
+#
+# On a Unix system, the normal procedure is to have 'post-commit'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'post-commit' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'post-commit.bat' or 'post-commit.exe',
+# but the basic idea is the same.
+#
+
+REPOS="$1"
+REV="$2"
+
+
+#
+# New Mailer script hooks
+#
+MAILER_SCRIPT=/opt/subversion/mailer_boost.py
+SVNDIR=/home/subversion/boost
+${MAILER_SCRIPT} commit "${SVNDIR}" "$REV" ${SVNDIR}/conf/mailer_dikim.conf
+
+LOG=`/usr/bin/svnlook log -r $REV $REPOS`
+AUTHOR=`/usr/bin/svnlook author -r $REV $REPOS`
+TRAC_ENV='/opt/trac/boost/'
+TRAC_URL='http://svn.boost.org/trac/boost/'
+#export PYTHONPATH="/opt/trac/lib/python2.3/site-packages/Trac-0.11-py2.3.egg/"
+export PYTHONPATH="/opt/trac2/lib/python2.4/site-packages/Trac-0.11.5-py2.4.egg/"
+
+/usr/bin/python24 /home/subversion/boost/hooks/trac-post-commit-hook \
+ -p "$TRAC_ENV" \
+ -r "$REV" \
+ -u "$AUTHOR" \
+ -m "$LOG" \
+ -s "$TRAC_URL"
+
+#
+# Update boost website
+#
+WEBDIR=/home/www/beta.boost.org
+cd $WEBDIR
+svn up
+cd /home/www/live.boost.org
+svn up

Added: trunk/tools/server/subversion/hooks/trac-post-commit-hook
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/trac-post-commit-hook 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,209 @@
+#!/opt/python-2.6/bin/python
+
+# trac-post-commit-hook
+# ----------------------------------------------------------------------------
+# Copyright (c) 2004 Stephen Hansen
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+# ----------------------------------------------------------------------------
+
+# This Subversion post-commit hook script is meant to interface to the
+# Trac (http://www.edgewall.com/products/trac/) issue tracking/wiki/etc
+# system.
+#
+# It should be called from the 'post-commit' script in Subversion, such as
+# via:
+#
+# REPOS="$1"
+# REV="$2"
+# TRAC_ENV="/path/to/tracenv"
+#
+# /usr/bin/python /usr/local/src/trac/contrib/trac-post-commit-hook \
+# -p "$TRAC_ENV" -r "$REV"
+#
+# (all the other arguments are now deprecated and not needed anymore)
+#
+# It searches commit messages for text in the form of:
+# command #1
+# command #1, #2
+# command #1 & #2
+# command #1 and #2
+#
+# Instead of the short-hand syntax "#1", "ticket:1" can be used as well, e.g.:
+# command ticket:1
+# command ticket:1, ticket:2
+# command ticket:1 & ticket:2
+# command ticket:1 and ticket:2
+#
+# In addition, the ':' character can be omitted and issue or bug can be used
+# instead of ticket.
+#
+# You can have more than one command in a message. The following commands
+# are supported. There is more than one spelling for each command, to make
+# this as user-friendly as possible.
+#
+# close, closed, closes, fix, fixed, fixes
+# The specified issue numbers are closed with the contents of this
+# commit message being added to it.
+# references, refs, addresses, re, see
+# The specified issue numbers are left in their current status, but
+# the contents of this commit message are added to their notes.
+#
+# A fairly complicated example of what you can do is with a commit message
+# of:
+#
+# Changed blah and foo to do this or that. Fixes #10 and #12, and refs #12.
+#
+# This will close #10 and #12, and add a note to #12.
+
+import re
+import os
+import sys
+from datetime import datetime
+from optparse import OptionParser
+
+parser = OptionParser()
+depr = '(not used anymore)'
+parser.add_option('-e', '--require-envelope', dest='envelope', default='',
+ help="""
+Require commands to be enclosed in an envelope.
+If -e[], then commands must be in the form of [closes #4].
+Must be two characters.""")
+parser.add_option('-p', '--project', dest='project',
+ help='Path to the Trac project.')
+parser.add_option('-r', '--revision', dest='rev',
+ help='Repository revision number.')
+parser.add_option('-u', '--user', dest='user',
+ help='The user who is responsible for this action '+depr)
+parser.add_option('-m', '--msg', dest='msg',
+ help='The log message to search '+depr)
+parser.add_option('-c', '--encoding', dest='encoding',
+ help='The encoding used by the log message '+depr)
+parser.add_option('-s', '--siteurl', dest='url',
+ help=depr+' the base_url from trac.ini will always be used.')
+
+(options, args) = parser.parse_args(sys.argv[1:])
+
+if not 'PYTHON_EGG_CACHE' in os.environ:
+ os.environ['PYTHON_EGG_CACHE'] = os.path.join(options.project, '.egg-cache')
+
+from trac.env import open_environment
+from trac.ticket.notification import TicketNotifyEmail
+from trac.ticket import Ticket
+from trac.ticket.web_ui import TicketModule
+# TODO: move grouped_changelog_entries to model.py
+from trac.util.text import to_unicode
+from trac.util.datefmt import utc
+from trac.versioncontrol.api import NoSuchChangeset
+
+ticket_prefix = '(?:#|(?:ticket|issue|bug)[: ]?)'
+ticket_reference = ticket_prefix + '[0-9]+'
+ticket_command = (r'(?P<action>[A-Za-z]*).?'
+ '(?P<ticket>%s(?:(?:[, &]*|[ ]?and[ ]?)%s)*)' %
+ (ticket_reference, ticket_reference))
+
+if options.envelope:
+ ticket_command = r'\%s%s\%s' % (options.envelope[0], ticket_command,
+ options.envelope[1])
+
+command_re = re.compile(ticket_command)
+ticket_re = re.compile(ticket_prefix + '([0-9]+)')
+
+class CommitHook:
+ _supported_cmds = {'close': '_cmdClose',
+ 'closed': '_cmdClose',
+ 'closes': '_cmdClose',
+ 'fix': '_cmdClose',
+ 'fixed': '_cmdClose',
+ 'fixes': '_cmdClose',
+ 'addresses': '_cmdRefs',
+ 're': '_cmdRefs',
+ 'references': '_cmdRefs',
+ 'refs': '_cmdRefs',
+ 'see': '_cmdRefs'}
+
+ def __init__(self, project=options.project, author=options.user,
+ rev=options.rev, url=options.url):
+ self.env = open_environment(project)
+ repos = self.env.get_repository()
+ repos.sync()
+
+ # Instead of bothering with the encoding, we'll use unicode data
+ # as provided by the Trac versioncontrol API (#1310).
+ try:
+ chgset = repos.get_changeset(rev)
+ except NoSuchChangeset:
+ return # out of scope changesets are not cached
+ self.author = chgset.author
+ self.rev = rev
+ self.msg = "(In [%s]) %s" % (rev, chgset.message)
+ self.now = datetime.now(utc)
+
+ cmd_groups = command_re.findall(self.msg)
+
+ tickets = {}
+ for cmd, tkts in cmd_groups:
+ funcname = CommitHook._supported_cmds.get(cmd.lower(), '')
+ if funcname:
+ for tkt_id in ticket_re.findall(tkts):
+ func = getattr(self, funcname)
+ tickets.setdefault(tkt_id, []).append(func)
+
+ for tkt_id, cmds in tickets.iteritems():
+ try:
+ db = self.env.get_db_cnx()
+
+ ticket = Ticket(self.env, int(tkt_id), db)
+ for cmd in cmds:
+ cmd(ticket)
+
+ # determine sequence number...
+ cnum = 0
+ tm = TicketModule(self.env)
+ for change in tm.grouped_changelog_entries(ticket, db):
+ if change['permanent']:
+ cnum += 1
+
+ ticket.save_changes(self.author, self.msg, self.now, db, cnum+1)
+ db.commit()
+
+ tn = TicketNotifyEmail(self.env)
+ tn.notify(ticket, newticket=0, modtime=self.now)
+ except Exception, e:
+ # import traceback
+ # traceback.print_exc(file=sys.stderr)
+ print>>sys.stderr, 'Unexpected error while processing ticket ' \
+ 'ID %s: %s' % (tkt_id, e)
+
+
+ def _cmdClose(self, ticket):
+ ticket['status'] = 'closed'
+ ticket['resolution'] = 'fixed'
+
+ def _cmdRefs(self, ticket):
+ pass
+
+
+if __name__ == "__main__":
+ if len(sys.argv) < 5:
+ print "For usage: %s --help" % (sys.argv[0])
+ print
+ print "Note that the deprecated options will be removed in Trac 0.12."
+ else:
+ CommitHook()

Added: trunk/tools/server/subversion/hooks/trac-post-commit-hook.old
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/trac-post-commit-hook.old 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,207 @@
+#!/usr/bin/python24
+
+# trac-post-commit-hook
+# ----------------------------------------------------------------------------
+# Copyright (c) 2004 Stephen Hansen
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+# ----------------------------------------------------------------------------
+
+# This Subversion post-commit hook script is meant to interface to the
+# Trac (http://www.edgewall.com/products/trac/) issue tracking/wiki/etc
+# system.
+#
+# It should be called from the 'post-commit' script in Subversion, such as
+# via:
+#
+# REPOS="$1"
+# REV="$2"
+#
+# /usr/bin/python /usr/local/src/trac/contrib/trac-post-commit-hook \
+# -p "$TRAC_ENV" -r "$REV"
+#
+# (all the other arguments are now deprecated and not needed anymore)
+#
+# It searches commit messages for text in the form of:
+# command #1
+# command #1, #2
+# command #1 & #2
+# command #1 and #2
+#
+# Instead of the short-hand syntax "#1", "ticket:1" can be used as well, e.g.:
+# command ticket:1
+# command ticket:1, ticket:2
+# command ticket:1 & ticket:2
+# command ticket:1 and ticket:2
+#
+# In addition, the ':' character can be omitted and issue or bug can be used
+# instead of ticket.
+#
+# You can have more then one command in a message. The following commands
+# are supported. There is more then one spelling for each command, to make
+# this as user-friendly as possible.
+#
+# close, closed, closes, fix, fixed, fixes
+# The specified issue numbers are closed with the contents of this
+# commit message being added to it.
+# references, refs, addresses, re, see
+# The specified issue numbers are left in their current status, but
+# the contents of this commit message are added to their notes.
+#
+# A fairly complicated example of what you can do is with a commit message
+# of:
+#
+# Changed blah and foo to do this or that. Fixes #10 and #12, and refs #12.
+#
+# This will close #10 and #12, and add a note to #12.
+
+import re
+import os
+import sys
+from datetime import datetime
+
+from trac.env import open_environment
+from trac.ticket.notification import TicketNotifyEmail
+from trac.ticket import Ticket
+from trac.ticket.web_ui import TicketModule
+# TODO: move grouped_changelog_entries to model.py
+from trac.util.text import to_unicode
+from trac.util.datefmt import utc
+from trac.versioncontrol.api import NoSuchChangeset
+
+from optparse import OptionParser
+
+parser = OptionParser()
+depr = '(not used anymore)'
+parser.add_option('-e', '--require-envelope', dest='envelope', default='',
+ help="""
+Require commands to be enclosed in an envelope.
+If -e[], then commands must be in the form of [closes #4].
+Must be two characters.""")
+parser.add_option('-p', '--project', dest='project',
+ help='Path to the Trac project.')
+parser.add_option('-r', '--revision', dest='rev',
+ help='Repository revision number.')
+parser.add_option('-u', '--user', dest='user',
+ help='The user who is responsible for this action '+depr)
+parser.add_option('-m', '--msg', dest='msg',
+ help='The log message to search '+depr)
+parser.add_option('-c', '--encoding', dest='encoding',
+ help='The encoding used by the log message '+depr)
+parser.add_option('-s', '--siteurl', dest='url',
+ help=depr+' the base_url from trac.ini will always be used.')
+
+(options, args) = parser.parse_args(sys.argv[1:])
+
+
+ticket_prefix = '(?:#|(?:ticket|issue|bug)[: ]?)'
+ticket_reference = ticket_prefix + '[0-9]+'
+ticket_command = (r'(?P<action>[A-Za-z]*).?'
+ '(?P<ticket>%s(?:(?:[, &]*|[ ]?and[ ]?)%s)*)' %
+ (ticket_reference, ticket_reference))
+
+if options.envelope:
+ ticket_command = r'\%s%s\%s' % (options.envelope[0], ticket_command,
+ options.envelope[1])
+
+command_re = re.compile(ticket_command)
+ticket_re = re.compile(ticket_prefix + '([0-9]+)')
+
+class CommitHook:
+ _supported_cmds = {'close': '_cmdClose',
+ 'closed': '_cmdClose',
+ 'closes': '_cmdClose',
+ 'fix': '_cmdClose',
+ 'fixed': '_cmdClose',
+ 'fixes': '_cmdClose',
+ 'addresses': '_cmdRefs',
+ 're': '_cmdRefs',
+ 'references': '_cmdRefs',
+ 'refs': '_cmdRefs',
+ 'see': '_cmdRefs'}
+
+ def __init__(self, project=options.project, author=options.user,
+ rev=options.rev, url=options.url):
+ self.env = open_environment(project)
+ repos = self.env.get_repository()
+ repos.sync()
+
+ # Instead of bothering with the encoding, we'll use unicode data
+ # as provided by the Trac versioncontrol API (#1310).
+ try:
+ chgset = repos.get_changeset(rev)
+ except NoSuchChangeset:
+ return # out of scope changesets are not cached
+ self.author = chgset.author
+ self.rev = rev
+ self.msg = "(In [%s]) %s" % (rev, chgset.message)
+ self.now = datetime.now(utc)
+
+ cmd_groups = command_re.findall(self.msg)
+
+ tickets = {}
+ for cmd, tkts in cmd_groups:
+ funcname = CommitHook._supported_cmds.get(cmd.lower(), '')
+ if funcname:
+ for tkt_id in ticket_re.findall(tkts):
+ func = getattr(self, funcname)
+ tickets.setdefault(tkt_id, []).append(func)
+
+ for tkt_id, cmds in tickets.iteritems():
+ try:
+ db = self.env.get_db_cnx()
+
+ ticket = Ticket(self.env, int(tkt_id), db)
+ for cmd in cmds:
+ cmd(ticket)
+
+ # determine sequence number...
+ cnum = 0
+ tm = TicketModule(self.env)
+ for change in tm.grouped_changelog_entries(ticket, db):
+ if change['permanent']:
+ cnum += 1
+
+ ticket.save_changes(self.author, self.msg, self.now, db, cnum+1)
+ db.commit()
+
+ tn = TicketNotifyEmail(self.env)
+ tn.notify(ticket, newticket=0, modtime=self.now)
+ except Exception, e:
+ # import traceback
+ # traceback.print_exc(file=sys.stderr)
+ print>>sys.stderr, 'Unexpected error while processing ticket ' \
+ 'ID %s: %s' % (tkt_id, e)
+
+
+ def _cmdClose(self, ticket):
+ ticket['status'] = 'closed'
+ ticket['resolution'] = 'fixed'
+
+ def _cmdRefs(self, ticket):
+ pass
+
+
+if __name__ == "__main__":
+ if len(sys.argv) < 5:
+ print "For usage: %s --help" % (sys.argv[0])
+ print
+ print "Note that the deprecated options will be removed in Trac 0.12."
+ else:
+ CommitHook()

Added: trunk/tools/server/subversion/hooks/xml-check.sh
==============================================================================
--- (empty file)
+++ trunk/tools/server/subversion/hooks/xml-check.sh 2012-11-27 22:44:15 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# CHECKS THAT ALL XMLs THAT ARE TO BE COMMITED ARE PARSEABLE
+
+REPOS="$1"
+TXN="$2"
+
+OPTS="-t $TXN"
+
+SVNLOOK=/usr/bin/svnlook
+type=
+for token in `$SVNLOOK changed $OPTS $REPOS`
+do
+ if [ -z "$type" ]
+ then
+ type=$token
+ else
+ # Only checking a file if it wasn't deleted and is an .xml file
+ if [ "$type" != "D" -a -n "`echo $token | grep .*\.xml`" ]
+ then
+ $SVNLOOK cat $OPTS $REPOS $token | /usr/bin/xmllint -noout - || {
+ echo "Error parsing XML; aborting commit." >&2
+ exit 1
+ }
+ fi
+
+ # Resetting type to get the type for the next file
+ type=
+ fi
+done
+
+exit 0
\ No newline at end of file


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk