merge_trunk_to_branch 3.02 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
#!/bin/ksh
#
#  Script: merge_trunk_to_branch
# 
#  Purpose: 
#      Merges the trunk into a branch
#
#  Programmer: Hank Childs
#  Creation:   May 14, 2007
#
#  Modifications:
#
13 14 15
#    Hank Childs, Mon Dec 17 16:12:45 PST 2007
#    Explicitly enumerate the list of directories to merge over.
#
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
# *****************************************************************************

issueHelp="no"

P=$(whence $0)
P2=${P%/*}
. ${P2}/visit_svn_helper

# Prevent print statements when changing directories
CDPATH=""

BRANCH=""
if [[ $# != 0 ]] ; then
   issueHelp="yes"
elif [[ ! -f .branchname ]] ; then
   echo ""
   echo "ERROR: You must run this script at the top of your branch directory"
   echo ""
   issueHelp="yes"
elif [[ ! -f .rootpath ]] ; then
   echo ""
   echo "ERROR: You must run this script at the top of your branch directory"
   echo ""
   issueHelp="yes"
else
   BRANCHNAME=$(cat .branchname)
   ROOTPATH=$(cat .rootpath)
   BRANCH=${VISIT_SVN_BRANCHES}/${SVN_NERSC_NAME}/${BRANCHNAME}${ROOTPATH}
   svn ls $BRANCH 2>/dev/null > /dev/null
   if [[ $? != 0 ]] ; then
      echo "The branch $1 does not appear to exist."
      echo "(Looking for it at $BRANCH)"
      echo "Try using the script ls_branches to locate your branch."
      issueHelp="yes"
   fi
fi

if [[ "$issueHelp" == "yes" ]] ; then
   echo ""
   echo "Usage:   ${0##*/}"
   echo ""
   echo "Example: ${0##*/}"
58 59 60
   echo ""
   echo "\tThis command should be run at the top level of your checked out branch."
   echo "\tIt will use the contents of the file \".branchname\" to determine which branch "
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
   echo "\tto merge the trunk into."
   echo ""
   
   exit 1
fi


echo ""
echo "Merging trunk into branch $BRANCH"
echo ""

echo ""
echo "Getting record of last merge from trunk into branch..."

mkdir tmp_forRev$$
cd tmp_forRev$$
svn checkout --quiet ${VISIT_SVN_BRANCHES}/${SVN_NERSC_NAME}/${BRANCHNAME}/svninfo
cd svninfo
REV=$(cat Rev_fromTrunk)
cd ../..
echo "The revision of the last merge was $REV"
echo ""

84 85
for i in src data docs test third_party windowsbuild ; do
   if [[ -d $i ]] ; then
86 87 88 89 90 91 92 93
       cd $i
       echo ""
       echo "Merging directory \"$i\""
       echo ""
       svn merge -r ${REV}:HEAD ${VISIT_SVN_TRUNK}/${ROOTPATH}/$i
       cd ..
   fi
done
94
NEW_REV=$(get_latest_rev)
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

cd tmp_forRev$$/svninfo
echo "$NEW_REV" > Rev_fromTrunk
echo ""
echo "Updating branch $BRANCHNAME to contain a record of this merge..."
echo ""
svn commit --quiet -m "Update for revision sent from trunk to $BRANCHNAME, $REV to $NEW_REV"
cd ../..
rm -Rf tmp_forRev$$

echo ""
echo "The changes from the trunk have been put on your working copy."
echo "You need to review the changes and do an \"svn commit\" for these changes "
echo "to be saved.  Note that the branch has been updated with the info that this "
echo "merge took place and future merges from the trunk will not attempt to merge "
echo "these revisions again.  If you want to back out this merge, you will need "
echo "invoke the following command to update our bookkeeping: "
echo ""
echo "  set_trunk_to_branch_revision $BRANCHNAME $REV"
echo ""

return 0