#!/bin/sh -v

remote_user=$1
svn_path=`which svn`
config_dir=$PWD/config

#Create the repository:
rm -rf wc repos
svnadmin create repos
svn mkdir file://$PWD/repos/trunk -m '' 
svn co file://$PWD/repos/trunk wc
touch wc/afile
svn add wc/afile
svn propset svn:needs-lock '*' wc/afile
svn ci -m 'initial commit' wc

#Branch:
svn cp file://$PWD/repos/trunk file://$PWD/repos/branch -m 'branch'

#Make an edit on trunk:
svn lock wc/afile
echo "foo" >> wc/afile
svn ci -m 'modified afile' wc
svn unlock wc/afile

#Make the same edit on the branch:
svn sw file://$PWD/repos/branch wc
svn lock wc/afile
echo "foo" >> wc/afile
svn ci -m 'duplicate modification to afile' wc
svn unlock wc/*

#Switch to the trunk as a different user:
ssh -l $remote_user $HOSTNAME $svn_path sw --config-dir=$config_dir -r HEAD file://$PWD/repos/trunk $PWD/wc