#!/usr/bin/env bash

## TO MAKE THIS RUN YOUR CUSTOM COMPILED SVN, two simple options:
## 1. Adjust your PATH to point at your custom installed location:
##      export PATH="$HOME/prefix/svn_trunk/bin:$PATH"
## OR
## 2. Uncomment the four lines below to use aliases into your
##    built source tree. The next line is the only line you should
##    need to adjust.
# SVNDIR=/path/to/built_subversion_source_tree
# function svn() { "$SVNDIR/subversion/svn/svn" "$@"; }
# function svnserve() { "$SVNDIR/subversion/svnserve/svnserve" "$@"; }
# function svnadmin() { "$SVNDIR/subversion/svnadmin/svnadmin" "$@"; }

set -e

svn --version
BASE="$(mktemp -d "/tmp/$(basename "$0").XXX")"
echo "BASE = $BASE"
REPOS="$BASE/repos"
WC="$BASE/wc"
URL="file://$REPOS"
svnadmin create "$REPOS"

svn co -q "$URL" "$WC"

set +e
set -x
cd "$WC"

## ACTUAL TEST

mkdir A
echo a > A/remote_file
svn add A

svn ci -mm
svn up

mkdir XA
echo orig > XA/local_file
svn add XA
svn ci -mm

svn info XA | grep '^URL\|^Path'

echo very important local mod >> XA/local_file
svn st XA
svn diff XA

svn up
svn ls
svn ps svn:externals "^/A XA" .
svn ci -mm
# bring in external XA
svn up

svn info XA | grep '^URL\|^Path'
svn st XA
svn diff XA
ls XA/
cat XA/local_file

# Where is the very important local mod!!


## END
set +x
echo "BASE = $BASE"

