#! /bin/sh
###
### svn_prop_merge.sh - Script that tests the merge of properties.

### Where all the data is created.
runDir=/dev/shm/spm
### Repository URL to put the data in.  Leave empty to create a file
### based repository.
repo1=
repo2=

### We grep for "At revision", so the language must be C.
LANG=C
export LANG

if [ ! -d $runDir ]; then mkdir $runDir || exit 1; fi
cd $runDir
if [ x"$repo1" = x ]; then
    svnadmin create repo1 || exit 2
    repo1=file://$runDir/repo1
fi
if [ x"$repo2" = x ]; then
    svnadmin create repo2 || exit 2
    repo2=file://$runDir/repo2
fi
svn mkdir --parents -m "data directory added" $repo1/data/sub || exit 3
svn mkdir --parents -m "work directory added" $repo2/work/sub || exit 3
svn co $repo1/data || exit 4
svn co $repo2/work || exit 4
svn co $repo2/work work2 || exit 4

cd data
rev1=`svn up|sed -e 's/At revision //' -e 's/\.//'`
echo date > sub/script
svn add sub/script
svn ci -m "script added to data"

chmod +w sub/script
svn propset svn:executable "*" sub/script
echo exit >> sub/script
svn up
svn ci -m "script made executable"
rev2=`svn up|sed -e 's/At revision //' -e 's/\.//'`

cd ../work
svn up
echo About to svn merge $repo1/data@$rev1 $repo1/data@$rev2 `pwd`
svn merge $repo1/data@$rev1 $repo1/data@$rev2 `pwd`
echo Status of directory work after the merge:
svn status -u
svn up
echo Directory work after the merge:
ls -l sub/script
svn ci -m "script in work updated"
echo Directory work after the commit:
ls -l sub/script
svn up
echo Status of directory work after the merge:
svn status -u
echo Properties for script in work:
svn proplist sub/script
echo Value of svn:executable:
svn propget svn:executable sub/script

cd ../work2
svn up
echo Directory work2 after the merge:
ls -l sub/script
echo Status of directory work2 after the update:
svn status -u
echo Properties for script in work2:
svn proplist sub/script
echo It is an error if the previous command does not list the svn:executable property.
