#!/bin/bash
if [[ $# -eq 0 ]] || [[ $1 == "-h" ]] ; then
echo "Usage: ${0##*/}
[more dirs]"
exit 1
fi
dir=$1
if [[ ! -e ${dir} ]] ; then
echo "cvs-import: $1: directory does not exist" 1>&2
exit 1
fi
dir=$(realpath "${dir}")
echo "Importing ${dir} and kids"
cd ${dir}/..
cvs -Q add ${dir##*/}
find_files() {
find . -mindepth $1 -maxdepth $1 '!' '(' -name 'CVS' -o -wholename '*/CVS/*' ')' -print0
}
cd ${dir}
i=1
while [[ -n $(find_files ${i}) ]] ; do
echo "Importing at depth ${i}"
find_files ${i} | xargs -0 cvs -Q add
((++i))
done
echo "Done"