#!/bin/sh

ignore=".cvsignore"
checkIgnore()
{
	for i in $ignore; do
		if [ "$i" == "$1" ]; then
			return 1
		fi
	done
	return 0
}

getCVSEntries()
{
	if [ \! -d "$1" ]; then
		echo "ERROR: Directory '$1' does not exists!" 2>&2
		exit 1
	fi
	if [ \! -e "$1/CVS/Entries" ]; then
		echo "ERROR: CVS/Entries in '$1' not found!" 1>&2
		exit 1
	fi
	entries=`cat "$1/CVS/Entries"`
	dirs=`echo "$entries" | grep -e "^D/.*" | cut -d/ -f2`
	files=`echo "$entries" | grep -e "^/.*" | cut -d/ -f2`
	for f in $files; do
		checkIgnore "$f"
		if [ "$?" -eq 0 ]; then
			all_files="$all_files $1/$f"
		fi
	done
	for d in $dirs; do
		getCVSEntries "$1/$d"
	done
}

if [ "$1" == "" ]; then
	echo "Usage: $0 <directors>"
	exit 1
fi

for searchdir in $*; do
	getCVSEntries "$searchdir"
	for f in $all_files; do
		echo "$f"
	done
done
#echo "$all_files"
