Re: SourceForge CVS changes

Robert Ellison <[email protected]> Tue, 16 May 2006 09:07:47 -0600
Newsgroups gmane.comp.graphics.chromium.devel,gmane.comp.graphics.chromium.user
Organization Tungsten Graphics, Inc.
Message-ID <[email protected]>
> If you want to update all the CVS/Root files in your current CVS tree, 
> replace the old hostname:
> 
>     cvs.sourceforge.net
> 
> with the new one:
> 
>     chromium.cvs.sourceforge.net
> 
> Maybe someone handy with shells scripts can post a 'find/sed' command to 
> do this.
	$ cd <chromiumDirectory>
	$ cvsmv cvs.sourceforge.net chromium.cvs.sourceforge.net

Bob Ellison
Self-proclaimed Script Meister
Tungsten Graphics, Inc.
cvsmv (text/plain, 1.3 KB)
#!/bin/bash
prog=${0##*/}

#
# Things to do if you catch an interrupt
#
trap "rm -f /tmp/$prog$$*" 0
trap "rm -f /tmp/$prog$$*; exit 2" 1 2 3 15

#
# Set variables to default values
#
verbose=no
directory=.
tmpFileList=/tmp/$prog$$A
tmpEditedFile=/tmp/$prog$$B

#
# Parse command-line options
#

options=":hxd:"
while getopts "$options" arg
do
    case "$arg" in
	h) {
	    echo "Usage: $prog [-${options#:}] /old-cvsroot /new-cvsroot"
	    echo "Change all references in CVS/Root files from the old CVS root to the new one"
	    echo "-h gives help"
	    echo "-x for debug"
	    echo "-d specifies directory [$directory]"
	    } 1>&2
	    exit 1
	    ;;
	x)  verbose=yes ; set -x ;;
	:)  echo "$prog: $OPTARG requires an argument.  Use -h for help." 1>&2
	    exit 2
	    ;;
	*)  {
	    echo "$prog: unknown option '$OPTARG'.  Use -h for help."
	    } 1>&2
	    exit 2
    esac
done
shift $(($OPTIND - 1))

if [ $# -ne 2 ]; then
    echo "$prog: need exactly 2 arguments.  Use -h for help." 1>&2
    exit 2
fi

# Get all the files that refer to the old CVS root
find $directory -path '*CVS/Root' | xargs grep -l $1 > $tmpFileList

# Edit them one at a time.
cat $tmpFileList | while read file; do
    sed -e "s%$1%$2%g" < $file > $tmpEditedFile
    mv $tmpEditedFile $file
done


exit 0