#!/bin/sh

## A simple loop to just keep making more and more revisions to
## this file in the repository

## Note that the repository in this case is set up already
## and has /trunk (at least)
REPO='http://svn.sinz.org:8001/svn/test'

error()
{
   echo "$*"
   exit 1
}

makeRevs()
{
   dir="svn-test-`date '+%Y-%m-%d_%H-%M-%S'`_$1"
   cd /tmp
   mkdir $dir || error "Failed to create $dir in /tmp"
   cd $dir || error "Failed to cd /tmp/$dir"
   rdir="$REPO/trunk/$dir"
   echo "Creating repository directory $rdir"
   svn mkdir -q -m "Another test thread: $1" "$rdir" || error "Failed to create $rdir in repository"
   sleep 5
   echo "checking out repository directory $rdir"
   svn co -q "$rdir" . || error "Failed to check out $rdir"
   sleep 5
   revs=0
   echo "Starting 100 revisions into $rdir"
   echo "Starting: `date`" >test.txt
   cp test.txt other.txt
   cp other.txt last.txt
   svn add -q test.txt other.txt last.txt

   while [ "$revs" -lt "100" ]; do
      let "revs = $revs + 1"
      date >> test.txt
      tail -20 test.txt > other.txt
      tail -10 other.txt > last.txt
      head -5 other.txt >> last.txt
      svn commit -q -m "Testing $1 another revision: $revs"
   done

   cd /tmp
   rm -rf $dir
}

makeRevs 1 &
sleep 2
makeRevs 2 &
sleep 2
makeRevs 3 &
sleep 2
makeRevs 4 &
sleep 2
makeRevs 5 &
sleep 2
makeRevs 6 &
sleep 2
makeRevs 7 &
sleep 2
makeRevs 8 &
sleep 2
makeRevs 9 &
wait
echo "All done..."


