#!/bin/ksh

set -x

# Clean up from previous test
cd
rm -rf repo test-repo

# Create the repository
mkdir repo
svnadmin create ~/repo/test-repo

# Create the successful pre-lock hook
echo "#!/bin/ksh
exit 0" > ~/repo/test-repo/hooks/pre-lock
chmod 777 ~/repo/test-repo/hooks/pre-lock

# Create the failing post-lock hook
echo "#!/bin/ksh
exit 1" > ~/repo/test-repo/hooks/post-lock
chmod 777 ~/repo/test-repo/hooks/post-lock

# Create a wroking copy
svn co file:///home/gtroccol/repo/test-repo ~/test-repo
cd ~/test-repo

# Add a file with the svn:needs-lock property
echo "Old file" > file
svn add file
svn ps svn:needs-lock yes file
svn ci -m"Adding file"

# Lock the file before editing it
svn lock file

# Show the (wrong) status and that the file is read-only
svn st -u -q
ls -l file

# Modify the file and try to commit
echo "New line" >> file
svn st -u -q
