The aim is to maintain 2 separate repositories that are not strictly mirrored. Both repositories are be subject to update by different developers so svnsynch is out of the question.
Hooking the script might not be the right solution either as I would much prefer to run the script at will rather than with every commit. Perhaps a script to compare timestamps and copy the youngest? Please dont recommend that we change to git.
I'm linking to a hook script I use to check out a part of a repository every time it's committed to. You could probably modify it to suit your needs; I imagine you'd want to change the svn checkout
to svn export
.
For posterity I'll copy the text of the script here:
#!/bin/bash
# POST-COMMIT HOOK
#
# This is an SVN post-commit hook to automatically update a directory with the contents
# of some part of the SVN repository every time that part of the repository is changed.
fail() {
echo "$@" 1>&2
exit 1
}
# USER and PASS are the username and password of an SVN user with read access to the
# relevant part of the repository
USER=""
PASS=""
# The root of the SVN repository
SVNROOT=""
# The path within the SVN repository to export whenever it's committed
SVNPATH=""
# The directory to hold the checked-out copy
WORKING=""
# Since environment variables are unset
export PATH="/bin:/usr/bin:/usr/local/bin"
getopt=$(which getopt)
TEMP=`$getopt -o u:p:U:P:d: --long user:,pass:,password:,svn-root:,svn-path:,working-dir: -n $0 -- "$@"`
if [ $? != 0 ]; then
fail "Terminating...getopt failed"
fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
while true; do
case "$1" in
-u|--user)
USER=$2
shift 2;;
-p|--pass|--password)
PASS=$2
shift 2;;
-U|--svn-root)
SVNROOT=$2
shift 2;;
-P|--svn-path)
SVNPATH=$2
shift 2;;
-d|--working-dir)
WORKING=$2
shift 2;;
--)
shift
break ;;
*)
fail "Option error!";;
esac
done
test -n $SVNROOT || fail "Missing option --svn-root"
test -n $SVNPATH || fail "Missing option --svn-path"
test -n $WORKING || fail "Missing option --working-dir"
REPOS="$1"
REV="$2"
# The path to SVN executables
svnbin=$(which svn)
svnlook=$(which svnlook)
# The path to grep
grep=$(which egrep)
if test -n "$USER"; then
AUTHSTR="--username $USER --password $PASS"
else
AUTHSTR=""
fi
svnexport="$svnbin export --revision $REV $AUTHSTR"
svnupdate="$svnbin update --revision $REV $AUTHSTR"
svncheckout="$svnbin checkout --revision $REV $AUTHSTR"
svnchanged="$svnlook changed $REPOS --revision $REV"
grepq="$grep -q"
# If anything in the desired path has been changed
if $svnchanged | $grepq "^[A-Z]+[[:space:]]+$SVNPATH"; then
# Check it out to the web root
if test -d $WORKING/.svn; then
$svnupdate $WORKING || fail "svnupdate failed"
else
$svncheckout file://$SVNROOT/$SVNPATH $WORKING || fail "svncheckout failed"
fi
fi