#!/bin/sh

# POST-REVPROP-CHANGE HOOK
#
#   [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.
#

REPOS="$1"
REV="$2"
USER="$3"
PROPNAME="$4"
ACTION="$5"

SELF=`readlink -f $0`
CONF=`dirname ${SELF}`/hook.conf
if [ -f ${CONF} ]; then
    . ${CONF}
else
    echo "Missing hook configuration file" >&2
    exit -1
fi

export PYTHONPATH=$TRACPATH:$GENSHIPATH
export PYTHON_EGG_CACHE
export PYTHON=`which python2.5`
date >> "$LOGFILE"
echo "Revprop: $REV $PROPNAME" >> $LOGFILE
${PYTHON} ${HOOKPATH}/trac-revprop-hook -p "$TRAC_ENV" -u "$USER" \
    -n "$PROPNAME" -d "$REPOS" -r "$REV" -a "$ACTION" post 2>> "$LOGFILE"
if [ $? -ne 0 ]; then
    tail -5 "$LOGFILE" | \
      mail admin -s "[${REPOSNAME}] Unable to post-revprop revision ${REV}"
fi

