#! /bin/sh

endcomm="$1"

svnimport="/home/solo/bin/git-svnimport"
homedir="/home/solo/git/svnimport/"
logdir="/home/solo/git/svnimport/auto"
repname="httpd"
logname="svnimport.log"
delta=1000

num=1

StartComm()
{
	grep '^DONE:' "$logdir/$logname"|tail -n 3|head -n 1|cut -d' ' -f 2
}

cd "$homedir"

tstartcomm=`StartComm`
let tendcomm=$tstartcomm+$delta

while ((tendcom < endcomm))
do
	# echo "YES!"
	# exit
	(
		cd $repname
		rm -f .git/SVN2GIT_HEAD
		git-prune
		git-repack -a -d
	)
	
	mv "$logdir/$logname" "$logdir/$logname.$num"
	let num=$num+1
	
	echo "$svnimport -v -m -s $tstartcomm -l $tendcomm -S -F -T httpd/httpd/trunk -C $repname -L /home/solo/git/svnimport/list.txt -D http://svn.apache.org/repos/asf 2>>$logdir/$logname 1>>$logdir/$logname"
	"$svnimport" -v -m -s "$tstartcomm" -l "$tendcomm" -S -F -T httpd/httpd/trunk -C "$repname" -L /home/solo/git/svnimport/list.txt -D http://svn.apache.org/repos/asf 2>>"$logdir/$logname" 1>>"$logdir/$logname"

	tstartcomm=`StartComm`
	let tendcomm=$tstartcomm+$delta

done
