2 # cvs_importer: this tool does a recursive cvs add. it takes one or more
3 # directory names and recursively adds them to the cvs hierarchy they are
4 # currently located under (i.e., their parent directory).
6 if [ "$#" = "0" ]; then
7 echo "This program needs one or more directory names to recursively add."
11 function add_cvs_dir {
12 # loop across all the directories we were handed. these had better be
13 # arranged in hierarchically descending order or cvs will not like adding
16 if [ "$(basename $q)" == "CVS" ]; then
17 #echo "the parameter was cvs! -> $q"
21 #echo "just added directory $q"
25 function add_cvs_files {
26 # scans through the list of directories we were given. each directory is
27 # assumed to have some files which need to be added. we will add those
28 # files to cvs on a per directory basis to avoid clogging up the command
31 if [ "$(basename $q)" == "CVS" ]; then
32 #echo "skipping parameter as cvs! -> $q"
38 echo "Skipping badly erroneous directory $i. Logic error?"
42 # add all the files in this directory, but don't do subdirectories.
43 file_list=$(find . -maxdepth 1 -type f)
44 # make sure there are actually some files there.
45 if [ ! -z "$file_list" ]; then
46 find . -maxdepth 1 -type f -exec cvs add "{}" '+'
47 #echo "just added those files to $q directory"
50 # go back to where we were before jumping into the directory.
55 # main activity of script occurs starting here...
57 # loop across the directory names we were given on the command line.
59 # change into the directory just above the directory to add.
60 parent_dir=$(dirname $i)
61 adding_dir=$(basename $i)
62 pushd $parent_dir &>/dev/null
64 echo "Skipping erroneous parent directory $parent_dir."
67 #echo dir is now: $(pwd)
69 # find all the directories starting at the real directory to add, and add
70 # cvs repositories for each of them.
71 add_cvs_dir $(find $adding_dir -type d)
73 # now add all the files, since all of the directories should be listed
75 add_cvs_files $(find $adding_dir -type d)
77 # go back to the directory where we were previously.