#!/bin/sh

# The next line is the only line you should need to adjust.
SVNDIR=/Users/scelis/src/subversion-1.6.0

SVN=${SVNDIR}/subversion/svn/svn
SVNSERVE=${SVNDIR}/subversion/svnserve/svnserve
SVNADMIN=${SVNDIR}/subversion/svnadmin/svnadmin

# Select an access method.  If svn://, the svnserve setup is
# handled automagically by this script; but if http://, then
# you'll have to configure it yourself first.
# 
# URL=http://localhost/SOMETHING/repos
# URL=svn://localhost/repos
URL=file:///`pwd`/repos

rm -rf repos wc import-me

${SVNADMIN} create repos

# These are for svnserve only.
echo "[general]" > repos/conf/svnserve.conf
echo "anon-access = write" >> repos/conf/svnserve.conf
echo "auth-access = write" >> repos/conf/svnserve.conf

# The server will only be contacted if $URL is svn://foo, of course.
${SVNSERVE} --pid-file svnserve-pid -d -r `pwd`
# And put the kill command in a file, in case need to run it manually.
echo "kill -9 `cat svnserve-pid`" > k
chmod a+rwx k

# Create a repository with two branches each containing one, identical file.
mkdir import-me
mkdir import-me/project
mkdir import-me/project/trunk
mkdir import-me/project/trunk/files
mkdir import-me/project/trunk/uninteresting
mkdir import-me/project/branches
mkdir import-me/project/branches/1.0
mkdir import-me/project/branches/1.0/files
mkdir import-me/project/branches/1.0/uninteresting
echo "Contents of foo.txt" > import-me/project/trunk/files/foo.txt
echo "Contents of foo.txt" > import-me/project/branches/1.0/files/foo.txt

(cd import-me; ${SVN} import -q -m "Initial import." ${URL})

# Run the reproduction recipe.

# Sparsely checkout the local copy.
${SVN} co -q --depth=files ${URL} wc
${SVN} up -q --depth=files wc/project
${SVN} up -q --depth=files wc/project/trunk
${SVN} up -q wc/project/trunk/files
${SVN} up -q --depth=files wc/project/branches
${SVN} up -q --depth=files wc/project/branches/1.0
${SVN} up -q wc/project/branches/1.0/files

# Modify the file.
echo "Additional content." >> wc/project/trunk/files/foo.txt

# Commit.
${SVN} commit -q wc -m "This is my commit to trunk."

# Update.
${SVN} up -q wc

# Change to branch and merge.
cd wc/project/branches/1.0

echo ""
echo "### 'svn merge -c2 ../../trunk' output should show something being merged:"
echo ""

${SVN} merge -c2 ../../trunk

echo ""
echo "### 'svn st' output should show foo.txt as being changed:"
echo ""

${SVN} st

echo ""
echo "### 'svn diff' output:"
echo ""

${SVN} diff

# Put kill command in a file, in case need to run it manually.
cd ../../../..
./k


