2007, April 2 - 15:46 — Sarath
The provided scripts migrates an RCS directory to a CVS repository with out loosing history and logging information associated with the files.
#!/bin/bash
# CHANGE HERE !
# RCS controlled directory.
src_dir= projectdir
# This CVSROOT should point to this directory if CVSROOT is not mounted locally.
# Otherwise scp the directory to CVSROOT and set the permissions accordingly
dest_dir=mycvsroot
# NO CHANGES REQUIRED AFTER THIS
#________________________________________________________________________________________________
# Check for checked out (and locked) files.
UNLOCKED=$(grep '^locks' $(find . -type f -name '*,v') | grep -v 'locks;')
if [ -n "$UNLOCKED" ] ; then
printf "%d files are unlocked and should be checked in:\n" $(echo "$UNLOCKED" | wc -l)
echo "$UNLOCKED" | sed 's!:locks$!!'
exit 1
else
printf "Trying to export rcs directory [ %s ] to CVS " "$src_dir"
fi
#Get all rcs controlled files.
for f in $(find ${src_dir} -name *,v); do
# printf "\nProcessing %s \n" $f
dir=`dirname $f`
end=`basename $dir`
# If a file is controlled by RCS, It should be in a directory called RCS
if [ $end = "RCS" ] ;then
# This is the relative path of the file in the repository
dir2 = $dest_dir/`dirname $dir`
if [ ! -d $dir2 ] ; then
printf "\n\tCreating : %s \n" $dir2
mkdir -p $dir2
fi
# Now we can copy RSC file to CVS repository
printf "\t %s ---> %s \n" $f $dir2
cp $f $dir2
else
print "Not an RCS directory "
fi
done