diff --git a/build/land1.sh b/build/land1.sh index da2df67da12da38e7c0b3b85d4932b526e9de6e0..b0728c8132df53ac8a09a7977381198804cbd5c8 100755 --- a/build/land1.sh +++ b/build/land1.sh @@ -30,7 +30,7 @@ dir=${3:-.} module=$(basename $(<$dir/CVS/Repository)) if [ "$module" = "lustre" ] ; then - echo >&2 "${progname}: You probably want to land lustre or portals, not the whole tree." + echo >&2 "${progname}: You probably want to land lustre or lnet, not the whole tree." echo >&2 "${progname}: Try using ${0} $parent $child lustre" exit 1 fi diff --git a/build/land2.sh b/build/land2.sh index 26dce768c9629408dabd2d2ce67280ff438e385d..f662c242a89573fb28ee0263ee83afa584965e93 100755 --- a/build/land2.sh +++ b/build/land2.sh @@ -9,6 +9,12 @@ fi . .mergeinfo +if [ "$OPERATION" -ne "Land" ] ; then + echo "OPERATION must be Land - is $OPERATION" + echo "You should probably be running ${OPERATION}2.sh" + exit +fi + if [ -f "$CONFLICTS" ] ; then echo "$CONFLICTS exists - clean up first" cat $CONFLICTS diff --git a/build/replace1.sh b/build/replace1.sh new file mode 100755 index 0000000000000000000000000000000000000000..8a571378e3a22e80ff9004d0269a17d21f3aa07c --- /dev/null +++ b/build/replace1.sh @@ -0,0 +1,129 @@ +#!/bin/sh -e + +progname=${0##*/} + +CONFLICTS=cvs-merge-conflicts +CVS=cvs + +if [ -f .mergeinfo ] ; then + echo ".mergeinfo exists - clean up first" + exit +fi + +if [ -f $CONFLICTS ] ; then + echo "$CONFLICTS exists - clean up first" + exit +fi + +if [ $# -lt 2 -o $# -gt 3 ]; then + echo "This is phase 1 of replacing branches. Usage: $0 parent(old) child(new) [dir]" + exit +fi + +parent=$1 +PARENT=`echo $parent | sed -e "s/^b_//" | tr "[a-z]" "[A-Z]"` +child=$2 +CHILD=`echo $child | sed -e "s/^b_//" | tr "[a-z]" "[A-Z]"` +date=`date +%Y%m%d_%H%M` + +dir=${3:-.} +module=$(basename $(<$dir/CVS/Repository)) + +if [ "$module" = "lustre" ] ; then + echo >&2 "${progname}: You probably want to land lustre or lnet, not the whole tree." + echo >&2 "${progname}: Try using ${0} $parent $child lustre" + exit 1 +fi + +case $parent in + HEAD) : ;; + b_*|b[1-4]*) : ;; + *) parent="b_$parent" ;; +esac +case $child in + HEAD) : ;; + b_*|b[1-4]*) : ;; + *) child="b_$child" +esac + +if [ "$parent" != "HEAD" -a "`cat $dir/CVS/Tag 2> /dev/null`" != "T$parent" ]; then + echo "${progname}: this script must be run within the $parent branch" + exit 1 +fi + +TEST_FILE=${TEST_FILE:-ChangeLog} # does this need to be smarter? +check_tag() { + [ -z "$1" ] && echo "check_tag() missing arg" && exit3 + [ "$1" = "HEAD" ] && return + $CVS log ${dir%%/*}/$TEST_FILE 2> /dev/null | grep -q " $1: " && return + echo "${progname}: tag $1 not found in $dir/$TEST_FILE" + exit 2 +} + +check_tag $child +check_tag ${CHILD}_BASE + +cat << EOF > ".mergeinfo" +parent=$parent +PARENT=$PARENT +child=$child +CHILD=$CHILD +date=$date +module=$module +dir=$dir +CONFLICTS=$CONFLICTS +OPERATION=Replace +OPERWHERE=onto +EOF + +echo PARENT $PARENT parent $parent CHILD $CHILD child $child date $date + +# Update your tree to the PARENT branch; HEAD is not really a branch, so you +# need to update -A instead of update -r HEAD, or the commit will fail. -p +echo -n "Updating to $parent ...." +if [ $parent == "HEAD" ]; then + $CVS update -AdP $dir +else + $CVS update -r $parent -dP $dir +fi +echo "done" + +# Tag parent before merge +echo -n "Tagging as ${PARENT}_${CHILD}_REPLACE_PARENT_$date ..." +$CVS tag ${PARENT}_${CHILD}_REPLACE_PARENT_$date $dir +echo "done" + +# Tag child before merge +echo -n "Create land point on ${child} ${PARENT}_${CHILD}_REPLACE_CHILD_$date ..." +$CVS tag -r ${child} ${PARENT}_${CHILD}_REPLACE_CHILD_$date $dir +echo "done" + +# In case someone tries to re-land later +echo -n "Preserve old base tag ${CHILD}_BASE as ${CHILD}_BASE_PREV ..." +$CVS tag -F -r ${CHILD}_BASE ${CHILD}_BASE_PREV $dir +echo "done" + +# Apply all of the changes to your local tree: +echo -n "Updating as -j $parent -j $child ..." +$CVS update -j $parent -j $child $dir +echo "done" + +echo -n "Recording conflicts in $CONFLICTS ..." +$CVS update | awk '/^C/ { print $2 }' > $CONFLICTS +if [ -s $CONFLICTS ] ; then + echo "Conflicts found, fix before committing." + cat $CONFLICTS +fi + +$CVS diff --brief -r $CHILD $dir >> $CONFLICTS +if [ -s $CONFLICTS ] ; then + echo "Danger! The child branch $CHILD differs from the updated branch $dir" + cat $CONFLICTS +else + echo "No conflicts found" + rm -f $CONFLICTS +fi + +echo "done" + +echo "Build, test, commit and then run replace2.sh (no arguments)" diff --git a/build/replace2.sh b/build/replace2.sh new file mode 100755 index 0000000000000000000000000000000000000000..71a03fda14e66b395541780c1f3225875b97e845 --- /dev/null +++ b/build/replace2.sh @@ -0,0 +1,36 @@ +#!/bin/sh -e + +CVS=cvs + +if [ ! -f .mergeinfo ] ; then + echo ".mergeinfo doesn't exist - exit" + exit +fi + +. .mergeinfo + +if [ "$OPERATION" -ne "Replace" ] ; then + echo "OPERATION must be Replace - is $OPERATION" + echo "You should probably be running ${OPERATION}2.sh" + exit +fi + +if [ -f "$CONFLICTS" ] ; then + echo "$CONFLICTS exists - clean up first" + cat $CONFLICTS + exit +fi + +cvs update $dir 2>&1 | grep "^M" && echo "uncommitted changes" && exit 1 + +# Tag parent +echo -n "Tagging as ${CHILD}_REPLACED_${PARENT}_$date ..." +$CVS tag -F ${CHILD}_REPLACED_${PARENT}_$date $dir +echo "done" +# In case someone tries to re-land later +echo -n "Tagging as ${CHILD}_BASE ..." +$CVS tag -F ${CHILD}_BASE $dir + +echo "saving .mergeinfo as .mergeinfo-$date" +mv .mergeinfo .mergeinfo-$date +echo "done"