#!/bin/sh

# pass this script a bug number (from bugzilla.mcs.anl.gov/pvfs) and it will 
# - tag HEAD at point we will branch
# - create a branch (pvfs2-bugfix-XYZ) 
# - check out that branch to pvfs2-bugfix-XYZ directory

CVSROOT=${CVSROOT:-:ext:$USER@cvs.parl.clemson.edu:/projects/cvsroot}
PROJECT=pvfs2-1

usage="usage: $0 <-d CVSROOT> BUGNUMBER"
example="example: $0 66"

if [ $# -lt 1 ]; then
	echo $usage
	echo $example
	exit -1
fi

while getopts "d:" options; do
	case $options in
		d) CVSROOT=$OPTARG;;
		*) 
			echo $usage
			echo $example
			exit -1;
			;;
	esac
done

shift $(($OPTIND - 1))

# branch for bugfixing
cvs -d $CVSROOT rtag -b pvfs2-tag-bugfix-$1 $PROJECT
cvs -d $CVSROOT rtag -b pvfs2-bugfix-$1 $PROJECT

# check out branch into "pvfs2-bugfix-$1" directory 
cvs -d $CVSROOT checkout -d pvfs2-bugfix-$1 -r pvfs2-bugfix-$1 $PROJECT
