#!/bin/bash

# Difference between 1.4, 1.5:
# (1.4)

echo "set up subversion commands" >&2
#svn_version="1.5"
if [ "${svn_version:-1.4}" = "1.5" ]; then
	svn=$HOME/projects/3rdparty/install/bin/svn
	svnadmin=$HOME/projects/3rdparty/install/bin/svnadmin
else
	svn=/usr/bin/svn
	svnadmin=/usr/bin/svnadmin
fi

rm -rf /tmp/testcase
mkdir /tmp/testcase
pushd /tmp/testcase

echo "create a test repository using svn 1.4 or 1.5:" >&2
$svnadmin create old_repo
old_repo=file:///$(pwd)/old_repo

echo "prepare the repository tree structure" >&2
$svn mkdir -m "Create trunk and tags" $old_repo/trunk $old_repo/tags
$svn mkdir -m "Create pseudo-projects" $old_repo/trunk/m1 $old_repo/trunk/m2 $old_repo/trunk/m3 $old_repo/trunk/m4

echo "create a non-versioned local path to work in" >&2
mkdir ./base_dir
pushd ./base_dir

echo "check out m1 into $(pwd)" >&2
$svn co $old_repo/trunk/m1
popd

echo "check out the tag directory to create a new tag locally" >&2
$svn co $old_repo/tags
pushd tags
$svn mkdir tag_name
pushd tag_name

echo "here's the difference:  copy the 'm1' directory (which is an svn directory) from base_dir (which is not)" >&2
$svn cp ../../base_dir/m1 .
rc=$?
if [ $rc -ne 0 ]; then
	echo "FAILED TEST"
else
	$svn commit -m "Tagged"
fi	

# with 1.4:  succeeds
# with 1.5:  fails with: 
# svn: '../..' is not a working copy
# svn: Can't open file '../../.svn/entries': No such file or directory

popd
popd
popd

exit $rc