REPOS="$1"
TXN="$2"

# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`
if [ "$LOGMSG" -lt 4 ];
then
	echo -e "!!!!!! Need at least 4 charactors !!!!!!" 1<&2
	echo -e "!!!!!! Need at least 4 charactors !!!!!!" 1<&2
	echo -e "!!!!!! Need at least 4 charactors !!!!!!" 1<&2
	exit 1
fi 

# 5MB
maxsize=5242880
PNG_EXT="png"
JPG_EXT="jpg"

${SVNLOOK} changed -t "${TXN}" "${REPOS}" | while read status file
do
    [[ $status == "D" ]] && continue  # Skip Deletions
    [[ $file == */ ]] && continue     # Skip directories
	ext=`echo ${file} | awk -F"." '{print $NF}'`
	if [[ ${ext} = ${PNG_EXT} ]] || [[ ${ext} = ${JPG_EXT} ]]; then
		size=`$SVNLOOK -t $TXN filesize $REPOS $file`
		if [[ $size -gt $maxsize ]]; then
			echo -e "!!!!!! File '$file' too large to commit !!!!!!" 1<&2
			echo -e "!!!!!! File '$file' too large to commit !!!!!!" 1<&2
			echo -e "!!!!!! File '$file' too large to commit !!!!!!" 1<&2
			exit 1
		fi
	fi
done

exit 0