5 CONFLICTS=cvs-merge-conflicts
8 if [ -f .mergeinfo ] ; then
9 echo ".mergeinfo exists - clean up first"
13 if [ -f $CONFLICTS ] ; then
14 echo "$CONFLICTS exists - clean up first"
18 if [ $# -lt 2 -o $# -gt 3 ]; then
19 echo "This is phase 1 of replacing branches. Run this in the PARENT tree. Usage: $0 parent(will be replaced) child(will become the new parent) [dir]"
24 PARENT=`echo $parent | sed -e "s/^b_//" | tr "[a-z]" "[A-Z]"`
26 CHILD=`echo $child | sed -e "s/^b_//" | tr "[a-z]" "[A-Z]"`
27 date=`date +%Y%m%d_%H%M`
30 module=$(basename $(<$dir/CVS/Repository))
32 if [ "$module" = "lustre" ] ; then
33 echo >&2 "${progname}: You probably want to land lustre or lnet, not the whole tree."
34 echo >&2 "${progname}: Try using ${0} $parent $child lustre"
41 *) parent="b_$parent" ;;
49 if [ "$parent" != "HEAD" -a "`cat $dir/CVS/Tag 2> /dev/null`" != "T$parent" ]; then
50 echo "${progname}: this script must be run within the $parent branch"
54 TEST_FILE=${TEST_FILE:-ChangeLog} # does this need to be smarter?
56 [ -z "$1" ] && echo "check_tag() missing arg" && exit3
57 [ "$1" = "HEAD" ] && return
58 $CVS log ${dir%%/*}/$TEST_FILE 2> /dev/null | grep -q " $1: " && return
59 echo "${progname}: tag $1 not found in $dir/$TEST_FILE"
64 check_tag ${CHILD}_BASE
66 cat << EOF > ".mergeinfo"
79 echo PARENT $PARENT parent $parent CHILD $CHILD child $child date $date
81 # Update your tree to the PARENT branch; HEAD is not really a branch, so you
82 # need to update -A instead of update -r HEAD, or the commit will fail. -p
83 echo -n "Updating to $parent ...."
84 if [ $parent == "HEAD" ]; then
87 $CVS update -r $parent -dP $dir
91 # Tag parent before merge
92 echo -n "Create land-to point on $parent as ${PARENT}_${CHILD}_REPLACE_PARENT_$date ..."
93 $CVS rtag -r $parent ${PARENT}_${CHILD}_REPLACE_PARENT_$date $module
96 # Tag child before merge
97 echo -n "Create land-from point on ${child} ${PARENT}_${CHILD}_REPLACE_CHILD_$date ..."
98 $CVS rtag -r ${child} ${PARENT}_${CHILD}_REPLACE_CHILD_$date $module
101 # In case someone tries to re-land later
102 echo -n "Preserve old base tag on $parent ${CHILD}_BASE as ${CHILD}_BASE_PREV ..."
103 $CVS rtag -F -r ${CHILD}_BASE ${CHILD}_BASE_PREV $module
106 # Apply all of the changes to your local tree:
107 echo -n "Updating as -j $parent -j $child ..."
108 $CVS update -j $parent -j $child -dP $dir
111 echo -n "Recording conflicts in $CONFLICTS ..."
112 $CVS update $dir | awk '/^C/ { print $2 }' > $CONFLICTS
113 if [ -s $CONFLICTS ] ; then
114 echo "Conflicts found, fix before committing."
119 echo -n "Verifying that there are no diffs from $child ..."
120 $CVS diff --brief -r $child $dir >> $CONFLICTS
121 if [ -s $CONFLICTS ] ; then
122 echo "Danger! The child branch $CHILD differs from the updated branch $dir"
125 echo "No conflicts found"
130 echo "Build, test, commit and then run replace2.sh (no arguments)"