#!/bin/bash
set -e
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() {
local depth=$1
shift
find . -mindepth ${depth} -maxdepth ${depth} \
'!' '(' -name 'CVS' -o -wholename '*/CVS/*' ')' "$@"
}
cd "${dir}"
i=1
while [[ -n $(find_files ${i}) ]] ; do
echo "Importing at depth ${i}"
find_files ${i} -exec cvs -Q add {} +
: $(( i += 1 ))
done
echo "Done"