#!/bin/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
REPOS="`pwd`/repos"
URL="file://$REPOS"
rm -rf repos wc
svnadmin create repos

# enable all revprop changes
cat > repos/hooks/pre-revprop-change <<EOF
#!/bin/sh
exit 0;
EOF
chmod a+x repos/hooks/pre-revprop-change

svn co -q ${URL} wc

set +e
set -x
cd wc

mkdir dir_a
mkdir dir_b
svn add dir_a
svn add dir_b
svn ci -m "Adding dirs"

cat > dir_a/file << EOF
      _cur_solution.sinks(to_polarity(sinks))
                   .push(SinkInfo(_parent->place(),
                                  cktinfo->input_capacitance(),
                                  rat, sink_slew_limit));
   } else {
      _cur_solution.sinks(to_polarity(other)).append(csol.sinks().begin(),
                                                     csol.sinks().size());

      TimePair sink_slew_limit =
EOF

svn add dir_a/file
svn ci -m "Adding dir_a/file"

################################################################################
cat > dir_b/file << EOF
      _cur_solution.sinks(to_polarity(sinks))
                   .push(SinkInfo(_parent->place(),
                                  cktinfo->input_capacitance(),
                                  rat, sink_slew_limit));
   } else {
      _cur_solution.sinks(to_polarity(other)).append(csol.sinks().begin(),
                                                     csol.sinks().size());

      TimePair sink_slew_limit =
EOF

svn add dir_b/file
svn ci -m "Adding dir_b/file"
################################################################################

################################################################################
cat > dir_a/file << EOF
      _cur_solution.sinks(to_polarity(sinks))
                   .push(SinkInfo(_parent->place(),
                                  cktinfo->input_capacitance(),
                                  rat, sink_slew_limit));
   } else {
      _cur_solution.sinks(to_polarity(other)).append(csol.sinks());

      TimePair sink_slew_limit =
EOF

svn ci -m "Changing dir_a/file"
################################################################################


################################################################################
cat > dir_b/file << EOF
      _cur_solution.sinks(to_polarity(sinks))
                   .push(SinkInfo(_parent->place(),
                                  cktinfo->input_capacitance(),
                                  rat, sink_slew_limit));
   } else {

      _cur_solution.sinks(to_polarity(other)).append(csol.sinks());

      TimePair sink_slew_limit =
EOF

cd dir_b
svn merge -r 2:4 ${URL}/dir_a/ .