#!/bin/sh
 
if [ -z "$2" -o -z "$1" ] ; then
  echo usage: svn-dump repository dumpfile [end-version [start-version]]
  exit 1
fi
 
[ -f /etc/svntools.conf ] && source /etc/svntools.conf
[ -f $HOME/.svntoolsrc ] && source $HOME/.svntoolsrc
 
if [ -z $REPOS_BASE ] ; then
  echo "REPOS_BASE must be specified in /etc/svntools.conf or $HOME/.svntoolsrc"
  exit 2
fi

REPOS_BASE=`echo "$REPOS_BASE" | sed -e s/file:\\\/\\\///`

VERSION=""
if [ -n "$3" ] ; then
  VER_END="$3"
  VER_START="0"
  VERSION="--revision"
fi
if [ -n "$4" ] ; then
  VER_START="$4"
fi

if [ -n "$VERSION" ] ; then
  VERSION="$VERSION $VER_START:$VER_END"
fi

REPOS_BASE=`echo "$REPOS_BASE" | sed -e s/file:\\\/\\\///`
 
/usr/bin/svnadmin dump $REPOS_BASE/$1 $VERSION > $2
