From c9bd81d352c0e43db47d4846b97ee1ddd9565839 Mon Sep 17 00:00:00 2001
From: jacob <jacob>
Date: Fri, 3 Dec 2004 18:40:00 +0000
Subject: [PATCH] branch scripts

---
 build/branch.sh |  48 ++++++++++++++++++++
 build/land1.sh  | 118 ++++++++++++++++++++++++++++++++++++++++++++++++
 build/land2.sh  |  28 ++++++++++++
 build/merge1.sh | 103 ++++++++++++++++++++++++++++++++++++++++++
 build/merge2.sh |  29 ++++++++++++
 5 files changed, 326 insertions(+)
 create mode 100755 build/branch.sh
 create mode 100755 build/land1.sh
 create mode 100755 build/land2.sh
 create mode 100755 build/merge1.sh
 create mode 100755 build/merge2.sh

diff --git a/build/branch.sh b/build/branch.sh
new file mode 100755
index 0000000000..328aeffa5a
--- /dev/null
+++ b/build/branch.sh
@@ -0,0 +1,48 @@
+#!/bin/sh -e 
+CVS=${CVS:-cvs}
+
+progname=${0##*/}
+
+if [ $# -lt 2 -o $# -gt 3 ]; then
+    echo "This creates a new branch in CVS. Usage: $progname parent child <dir>"
+    exit
+fi
+
+parent=$1
+child=$2
+CHILD=`echo $child | sed -e "s/^b_//" | tr "[a-z]" "[A-Z]"`
+dir=${3:-.}
+module=$(<$dir/CVS/Repository)
+
+if [ "$module" = "lustre" ] ; then
+    echo >&2 "${progname}: You probably want to branch lustre or portals."
+    echo >&2 "${progname}: Try using ${0} $parent $child lustre"
+    exit 1
+fi
+
+case $parent in
+  HEAD) : ;;
+  b_*|b1*) : ;;
+  *) parent="b_$parent" ;;
+esac
+case $child in
+  HEAD) : ;;
+  b_*|b1*) : ;;
+  *) child="b_$child"
+esac
+
+if [ "$parent" != "HEAD" -a "`cat $dir/CVS/Tag`" != "T$parent" ]; then
+	echo "This script must be run within the $parent branch"
+	exit 1
+fi
+
+echo parent: $parent CHILD: $CHILD child: $child date: $date
+
+echo -n "tagging $parent as '${CHILD}_BASE' ...."
+$CVS rtag -r $parent ${CHILD}_BASE $module
+echo "done"
+echo -n "branching $child at ${CHILD}_BASE' ...."
+$CVS rtag -b -r ${CHILD}_BASE $child $module
+echo -n "updating $dir to $child ...."
+$CVS update -r $child $dir
+echo "done"
diff --git a/build/land1.sh b/build/land1.sh
new file mode 100755
index 0000000000..6b69eae5bd
--- /dev/null
+++ b/build/land1.sh
@@ -0,0 +1,118 @@
+#!/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 merging branches. Usage: $0 parent child [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=$(<$dir/CVS/Repository)
+
+if [ "$module" = "lustre" ] ; then
+    echo >&2 "${progname}: You probably want to branch lustre or portals, 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=Land
+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"
+
+echo -n "Tagging as ${PARENT}_${CHILD}_LAND_PARENT_$date ..."
+$CVS tag ${PARENT}_${CHILD}_LAND_PARENT_$date $dir
+echo "done"
+
+echo -n "Create land point on ${child} ${PARENT}_${CHILD}_LAND_CHILD_$date ..."
+$CVS rtag -r ${child} ${PARENT}_${CHILD}_LAND_CHILD_$date $module $dir
+echo "done"
+
+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 ${CHILD}_BASE -j ${PARENT}_${CHILD}_LAND_CHILD_$date ..."
+$CVS update -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_LAND_CHILD_$date $dir
+echo "done"
+
+echo -n "Recording conflicts in $CONFLICTS ..."
+if $CVS update | grep '^C' > $CONFLICTS; then
+    echo "Conflicts found, fix before committing."
+    cat $CONFLICTS
+else 
+    echo "No conflicts found"
+    rm -f $CONFLICTS
+fi
+echo "done"
+
+echo "Build, test, commit and then run land2.sh (no arguments)"
diff --git a/build/land2.sh b/build/land2.sh
new file mode 100755
index 0000000000..2bb9fade4c
--- /dev/null
+++ b/build/land2.sh
@@ -0,0 +1,28 @@
+#!/bin/sh -e 
+
+CVS=cvs
+
+if [ ! -f .mergeinfo ] ; then
+    echo ".mergeinfo doesn't exist - exit"
+    exit 
+fi
+
+. .mergeinfo
+
+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
+
+echo -n "Tagging as ${CHILD}_BASE_$date ..."
+$CVS tag -F ${CHILD}_BASE_$date $dir
+echo "done"
+echo -n "Tagging as ${CHILD}_BASE ..."
+$CVS tag -F ${CHILD}_BASE $dir
+
+echo "saving .mergeinfo as .mergeinfo-$date"
+mv .mergeinfo .mergeinfo-$date
+echo "done"
diff --git a/build/merge1.sh b/build/merge1.sh
new file mode 100755
index 0000000000..29130fa740
--- /dev/null
+++ b/build/merge1.sh
@@ -0,0 +1,103 @@
+#!/bin/sh -e 
+
+CONFLICTS=cvs-merge-conflicts
+CVS="cvs -z3"
+
+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 merging branches. Usage: $0 parent child [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=$(<$dir/CVS/Repository)
+
+if [ "$module" = "lustre" ] ; then
+    echo >&2 "${progname}: You probably want to branch lustre or portals, 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 [ "$child" != "HEAD" -a "`cat $dir/CVS/Tag 2> /dev/null`" != "T$child" ]; then
+	echo "This script must be run within the $child 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 "$0: tag $1 not found in $dir/$TEST_FILE"
+	exit 2
+}
+
+check_tag $parent
+check_tag ${CHILD}_BASE
+
+cat << EOF > .mergeinfo
+parent=$parent
+PARENT=$PARENT
+child=$child
+CHILD=$CHILD
+date=$date
+dir=$dir
+module=$module
+CONFLICTS=$CONFLICTS
+OPERATION=Merge
+OPERWHERE=from
+EOF
+
+echo PARENT: $PARENT parent: $parent CHILD: $CHILD child: $child date: $date
+
+echo -n "tagging $parent as '${PARENT}_${CHILD}_UPDATE_PARENT_$date' ...."
+$CVS rtag -r $parent ${PARENT}_${CHILD}_UPDATE_PARENT_$date $module
+echo "done"
+echo -n "tagging $child as '${PARENT}_${CHILD}_UPDATE_CHILD_$date' ...."
+$CVS rtag -r $child ${PARENT}_${CHILD}_UPDATE_CHILD_$date $module
+echo "done"
+
+# Apply all of the changes to your local tree:
+echo "Updating: -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_UPDATE_PARENT_$date ...."
+$CVS update -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_UPDATE_PARENT_$date -dP $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
+else 
+    echo "No conflicts found"
+    rm -f $CONFLICTS
+fi
+echo "done"
+
+echo "Build, test, commit and then run merge2.sh (no arguments)"
diff --git a/build/merge2.sh b/build/merge2.sh
new file mode 100755
index 0000000000..43586f062e
--- /dev/null
+++ b/build/merge2.sh
@@ -0,0 +1,29 @@
+#!/bin/sh -e 
+
+if [ ! -f .mergeinfo ] ; then
+    echo ".mergeinfo doesn't exist - exit"
+    exit 
+fi
+
+. .mergeinfo
+
+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
+
+echo -n "Tagging ${PARENT}_${CHILD}_UPDATE_PARENT_$date as ${CHILD}_BASE_$date ..."
+cvs rtag -r ${PARENT}_${CHILD}_UPDATE_PARENT_$date ${CHILD}_BASE_$date $module
+echo  "done"
+echo -n "Tagging ${CHILD}_BASE as ${CHILD}_BASE_PREV ...."
+cvs rtag -F -r ${CHILD}_BASE ${CHILD}_BASE_PREV $module
+echo  "done"
+echo "${CHILD}_BASE_$date as ${CHILD}_BASE ..."
+cvs rtag -F -r ${CHILD}_BASE_$date ${CHILD}_BASE $module
+
+echo "saving .mergeinfo as .mergeinfo-$date"
+mv .mergeinfo .mergeinfo-$date
+echo  "done"
-- 
GitLab