#!/bin/sh

REPOS=$PWD/svn.$$
REPOS_URL=file://$REPOS

svnadmin create --fs-type=fsfs $REPOS

# Import two directories
mkdir import
cd import
mkdir dir1 dir2
svn import -m 'initial import' . $REPOS_URL
cd ..

# Checkout from one directory and add an executable file
svn co $REPOS_URL/dir1
cd dir1
touch file
chmod +x file
svn add file
svn commit -m 'added executable file'
cd ..

# Checkout from dir2 and do the merge
svn co $REPOS_URL/dir2
cd dir2
svn merge -r1:2 $REPOS_URL/dir1

# Workaround svn merge not making the file executable
if [ ! -x file ];
then
	echo "Fixing up permissions on 'file'"
	chmod +x file
fi

# Show that the executable property exists and then remove it
svn proplist file
svn propdel svn:executable file

echo "svn status after removing svn:executable property:"
svn status file

svn commit -m 'removed svn:executable'

cd ..

# Checkout again and show the property is not removed
svn co $REPOS_URL/dir2 dir2withfile
cd dir2withfile
if [ -x file ];
then
	echo "'file' is still executable"
	exit 1
fi


