#!/bin/sh

# Reproduction recipe for issue 2740.
# Note that this needs sudo, see the call to chgrp below.

# Make sure $REPOS_URL points to `pwd`/repos, e.g.:
# <Location /repos>
# 	DAV svn
#	SVNPath /home/stsp/elego/2740/repos
# </Location>
REPOS_URL=http://localhost/repos

# You may also need to adjust this:
HTTPD_GROUP=www

DIR=`pwd`

set -e
set -x

# sudo because the httpd user creates files in repos/
sudo rm -rf repos ws1 ws2-file ws2-http

svnadmin create repos
chmod -R g+w repos
sudo chgrp -R $HTTPD_GROUP repos

# Create a subdirectory for sandwich.txt so we can spot
# regressions wrt the path printed in the error message.
# It should be relative to the top-level directory of the
# working copy.
mkdir -p ws1/dir
echo "Make me a sandwich!" > ws1/dir/sandwich.txt
(cd ws1 && svn import file://$DIR/repos/2740 \
                -m "Politely asking for a sandwich.")

svn co file://$DIR/repos/2740 ws2-file
svn co $REPOS_URL/2740 ws2-http

echo "What? Make it yourself!" >> ws2-file/dir/sandwich.txt
(cd ws2-file && svn commit -m "What a rude way to ask!")

rm -rf ws1
svn co file://$DIR/repos/2740 ws1
echo "sudo Make me a sandwich!" >> ws1/dir/sandwich.txt
(cd ws1 && svn commit -m "Using the force...")

set +e

echo "OK" >> ws2-file/dir/sandwich.txt
(cd ws2-file && svn commit -m "Trying to give in to the force via file://")

echo "OK" >> ws2-http/dir/sandwich.txt
(cd ws2-http && svn commit -m "Trying to give in to the force via http://")


