#!/bin/ksh

#set -x

# Clean up from previous test
cd
rm -rf repo test-repo test-repo-ext

# Create the repository
mkdir repo
svnadmin create /home/svn_gt/repo/test-repo

# Create a wroking copy
svn co file:///home/svn_gt/repo/test-repo /home/svn_gt/test-repo
cd /home/svn_gt/test-repo

# Create trunk and public
mkdir trunk trunk/dir trunk/dir/A1 trunk/dir/A2 trunk/dir/A3 trunk/dir/B public
svn add trunk public
svn ci -m"Creating trunk and public"
svn up

# Add the files
echo test1 > trunk/dir/A1/file1
echo test2 > trunk/dir/A2/file2
echo test3 > trunk/dir/A3/file3
echo test > trunk/dir/B/file
svn add trunk/dir/A1/file1 trunk/dir/A2/file2 trunk/dir/A3/file3 trunk/dir/B/file
svn ci -m"Adding file2 and file3"
svn up

# Create the file with the externals
echo "^/trunk/dir/A1/file1 dir/A1/file1" > test-repo-ext
echo "^/trunk/dir/A2 dir/A2" >> test-repo-ext
echo "^/trunk/dir/B B" >> test-repo-ext
echo "^/trunk/dir/A3/file3 B/file3B" >> test-repo-ext

# Create the external definition
svn ps svn:externals -F test-repo-ext public
svn ci -m"Creating the external in public for file2 and dir3"

# Update the wc
# file1 will NOT be fetched due to dir/A1 not being a working copy
# file2 will be fetched, even though dir/A2 doesn't exist, because the external is for the whole A2 directory
# file3 will be fetched because directory B already exist
svn up
