Solution to Trac and subversion on dreamhost.com with svnsync not showing correct users and commit messages

I installed Trac on dreamhost.com using CreamyTrac with an svnsynced Subversion repository from our local one, and the post-commit hook to do ‘close #3’ wasn’t working and the correct commit messages and users weren’t showing up until I did a trac-admin resync.

Most of the info I found on the web didn’t help, but I eventually solved it myself by using hook post-revprop-change instead of post-commit with the code shown below. This code only activates when svnsync is completely finished and has unlocked the destination repository, then it syncs the latest revision with Trac and then runs the Trac post-commit hook to close tickets, etc. Svnsync only seems to update commit messages and users after committing code, so Trac has the wrong information in post-commit, so you have to use post-revprop-change instead.

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

# Export bash variables required by trac.fcgi
export HOME="/home/me"
# Root directory for the Trac project
export TRAC_PROJECT_DIR="/home/me/trac_projects"
export TRAC_ENV="/home/me/trac_projects/myproj"

. ${HOME}/.bash_profile

if [ "$ACTION" = "D" -a "$PROPNAME" = "svn:sync-lock" ]; then
    YOUNGEST_REV=`svnlook youngest /home/me/svn/myproj`
    trac-admin $TRAC_ENV resync $YOUNGEST_REV
    ${RUN}/bin/python ${RUN}/share/trac/contrib/trac-post-commit-hook \
        -p "$TRAC_ENV" \
        -r "$YOUNGEST_REV"
fi
2009.05.13