Commit 8a3ef32f authored by hrchilds's avatar hrchilds

Add initial set of scripts for managing SVN.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@977 18c085ea-50e0-402c-830e-de6fd14e8384
parent fe6332c9
#!/bin/ksh
#
# Script: co_branch
#
# Purpose:
# Checks out a branch into the $PWD.
#
# Programmer: Hank Childs
# Creation: May 12, 2007
#
# Modifications:
#
# *****************************************************************************
issueHelp="no"
CDPATH="" # Prevent unneeded echoing of chdir's.
P=$(whence $0)
P2=${P%/*}
. ${P2}/visit_svn_helper
if [[ $# != 2 ]] ; then
issueHelp="yes"
fi
if [[ "$issueHelp" == "yes" ]] ; then
echo ""
echo "Usage: ${0##*/} <branch> <dir>"
echo "Usage: ${0##*/} <branch> <known-dir-combo>"
echo ""
echo "Example: ${0##*/} my_dev_work /src"
echo "\twill check out the /src directory of the branch my_dev_work "
echo "\tinto the subdirectory /my_dev_work"
echo ""
echo "Example: ${0##*/} my_dev_work /src/plots/Volume"
echo "\twill check out the /src/plots/Volume directory of the branch "
echo "\tmy_dev_work into the subdirectory /my_dev_work"
echo ""
echo "known-dir-combos: \"all\" (all subdirs), \"sdt\" (source-data-test)"
echo ""
echo "Example: ${0##*/} my_dev_work sdt"
echo "\twill check out the /src, /data/, and /test directories of the "
echo "\tbranch my_dev_work into the subdirectory /my_dev_work"
echo ""
echo "Note: you *can* check out different directories through multiple "
echo "invocations, for example: ${0##*/} branch /src followed by "
echo "${0##*/} branch /data"
echo ""
echo "But you *CANNOT* do this if the directories are at different levels "
echo "in the directory structure. For example, you *CANNOT* do "
echo "${0##*/} branch /src/plots/Volume and then later do ${0##*/} branch /src/"
echo ""
exit 1
fi
function checkout_dir
{
BRANCH=${VISIT_SVN_BRANCHES}/${SVN_NERSC_NAME}/${1}/${2#/}
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."
exit 1
fi
if [[ "${2#/}" == "${2}" ]] ; then
TMP="/${2}"
ROOT="${TMP%/*}"
else
ROOT="${2%/*}"
fi
if [[ "$ROOT" == "" ]] ; then
ROOT="/"
fi
if [[ -d ${1} ]] ; then
cd ${1}
if [[ ! -f .branchname ]] ; then
echo "The subdirectory I want to check out the files into appears to "
echo "be corrupted. It is missing the file \".branchname\"."
exit 1
fi
NAME=$(cat .branchname)
if [[ "$NAME" != "${1}" ]] ; then
echo "The subdirectory I want to place the check out in is for a "
echo "different branch. You are requesting ${1}, but it is for "
echo "branch $NAME"
exit 1
fi
if [[ ! -f .rootpath ]] ; then
echo "The subdirectory I want to check out the files into appears to "
echo "be corrupted. It is missing the file \".rootpath\"."
exit 1
fi
ROOT2=$(cat .rootpath)
if [[ "$ROOT" != "$ROOT2" ]] ; then
echo "The subdirectory I want to place the check out in is at a different "
echo "level of the directory hierarchy. You can still do a checkout "
echo "of this subdirectory, but you may not do it here, since it makes "
echo "merging too difficult. So you should go to a different directory "
echo "and issue this checkout command again."
echo "Your previous checkout(s) have been from ${ROOT2}"
echo "You are now requesting a checkout from ${ROOT}"
exit 1
fi
cd ..
else
mkdir ${1}
cd ${1}
echo ${1} > .branchname
chmod 400 .branchname
echo ${ROOT} > .rootpath
chmod 400 .rootpath
cd ..
fi
cd ${1}
echo "Getting files for \"${2}\" from remote repo..."
svn checkout --quiet --non-interactive $BRANCH
mkdir tmp_forRev$$
cd tmp_forRev$$
svn checkout --quiet ${VISIT_SVN_BRANCHES}/${SVN_NERSC_NAME}/${1}/svninfo > /dev/null
cd svninfo
init="notFound"
if [[ ! -f Rev_initial ]] ; then
echo "Cannot locate file Rev_initial ... is this a valid branch?"
else
init=$(cat Rev_initial)
fi
current="notFound"
if [[ ! -f Rev_fromTrunk ]] ; then
echo "Cannot locate file Rev_fromTrunk ... is this a valid branch?"
else
current=$(cat Rev_fromTrunk)
fi
cd ../../
rm -Rf tmp_forRev$$
if [[ "$current" != "$init" ]] ; then
stop="no"
while [[ "$stop" == "no" ]] ; do
echo ""
echo "ATTENTION"
echo ""
echo "A merge from the trunk has taken place on this branch previously."
echo "The branch was created at revision ${init}, but the merge took it to ${current}."
echo "It is not known whether the merge took place on the \"${2}\" directory"
echo "or not. You must decide if you would like to merge the changes "
echo "from ${init} to ${current} onto \"${2}\"."
echo ""
echo "You have three options: \"yes\", \"no\", and \"abort\"."
echo ""
echo "\"Yes\" means that you will do the merge and that the working copy "
echo "you receive will be at the current revision of the trunk."
echo ""
echo "\"No\" means that you will not do the merge and nothing will "
echo "change on this directory. If you have previously checked out "
echo "and done a merge on this directory, then this is the right "
echo "option. If you have *not* done a checkout or merge on this "
echo "directory before, then you will get the same revision of this "
echo "directory from when you issed \"mk_branch_from_trunk\"."
echo ""
echo "\"Abort\" will exit you from this script. The checkout of \"${2}\""
echo "has already occurred, but it was not merged and no further "
echo "directories will be checked out."
echo ""
echo "Enter \"yes\", \"no\", or \"abort\":"
read answer
if [[ "$answer" == "yes" ]] ; then
stop="yes"
fi
if [[ "$answer" == "no" ]] ; then
stop="yes"
fi
if [[ "$answer" == "abort" ]] ; then
stop="yes"
fi
done
if [[ "$answer" == "abort" ]] ; then
exit 1
elif [[ "$answer" == "yes" ]] ; then
echo ""
echo "Merging"
echo ""
if [[ "$init" == "notFound" ]] ; then
echo "Don't have the initial merging info ... can't proceed with merge"
else
RETURN_TO=${PWD}
cd ${2}
svn merge -r ${init}:HEAD ${VISIT_SVN_TRUNK}/$2
cd ${RETURN_TO}
fi
echo ""
echo "Done merging. Note: the changes were not automatically "
echo "committed. If there were changes, you will need to commit them."
echo ""
fi
fi
cd ..
}
if [[ "$2" == "sdt" ]] ; then
echo "Checking out /src"
checkout_dir $1 "/src"
echo "Checking out /data"
checkout_dir $1 "/data"
echo "Checking out /test"
checkout_dir $1 "/test"
elif [[ "$2" == "all" ]] ; then
echo "Checking out /src"
checkout_dir $1 "/src"
echo "Checking out /data"
checkout_dir $1 "/data"
echo "Checking out /test"
checkout_dir $1 "/test"
echo "Checking out /docs"
checkout_dir $1 "/docs"
echo "Checking out /third_party"
checkout_dir $1 "/third_party"
echo "Checking out /windowsbuild"
checkout_dir $1 "/windowsbuild"
else
checkout_dir $1 "$2"
fi
echo ""
echo "Your check out is ready!"
echo "cd to the \"$1\" directory to access the working copy."
echo ""
return 0
#!/bin/ksh
#
# Script: co_trunk
#
# Purpose:
# Checks out the trunk into the $PWD.
#
# Programmer: Hank Childs
# Creation: May 12, 2007
#
# Modifications:
#
# *****************************************************************************
issueHelp="no"
# Supresses print statement when you change directories
CDPATH=""
P=$(whence $0)
P2=${P%/*}
. ${P2}/visit_svn_helper
if [[ $# == 1 ]] ; then
if [[ "$1" == "-help" || "$1" == "-h" || "$1" == "-?" ]] ; then
issueHelp="yes"
fi
else
issueHelp="yes"
fi
if [[ "$issueHelp" == "yes" ]] ; then
echo ""
echo "Usage: ${0##*/} <dir>"
echo "Usage: ${0##*/} <known-dir-combo>"
echo ""
echo "Example: ${0##*/} /src"
echo "\twill check out the /src directory of the trunk into the subdirectory /trunk"
echo ""
echo "Example: ${0##*/} /src/plots/Volume"
echo "\twill check out the /src/plots/Volume directory of the trunk "
echo "\tinto the subdirectory trunk"
echo ""
echo "known-dir-combos: \"all\" (all subdirs), \"sdt\" (source-data-test)"
echo ""
echo "Example: ${0##*/} sdt"
echo "\twill check out the /src, /data/, and /test directories of the "
echo "\ttrunk into the subdirectory /trunk"
echo ""
echo "Note: you *can* check out different directories through multiple "
echo "invocations, for example: ${0##*/} /src followed by "
echo "${0##*/} /data"
echo ""
echo "But you *CANNOT* do this if the directories are at different levels "
echo "in the directory structure. For example, you *CANNOT* do "
echo "${0##*/} /src/plots/Volume and then later do ${0##*/} /src/"
echo ""
exit 1
fi
DIR=""
ROOT="/"
if [[ "$1" != "all" && "$1" != "sdt" ]] ; then
svn ls ${VISIT_SVN_TRUNK}/${1} 2>/dev/null > /dev/null
if [[ $? != 0 ]] ; then
echo "The trunk location $1 does not appear to exist."
echo "Aborting checkout"
exit 1
fi
if [[ "${1#/}" == "${1}" ]] ; then
TMP="/${1}"
ROOT="${TMP%/*}"
else
ROOT="${1%/*}"
fi
if [[ "$ROOT" == "" ]] ; then
ROOT="/"
fi
fi
function checkout_dir
{
cd trunk
echo "Getting files for \"${1}\" from remote repo..."
svn checkout --quiet --non-interactive ${VISIT_SVN_TRUNK}/${1}
cd ..
}
if [[ -d trunk ]] ; then
cd trunk
if [[ ! -f .branchname ]] ; then
echo "The subdirectory I want to place the check out in (trunk) does not appear "
echo "to be a valid check out."
exit 1
fi
NAME=$(cat .branchname)
if [[ "$NAME" != "trunk" ]] ; then
echo "The subdirectory I want to place the check out in (trunk) does not appear "
echo "to be a valid check out."
exit 1
fi
if [[ ! -f .rootpath ]] ; then
echo "The subdirectory I want to place the check out in is not consistent"
exit 1
fi
ROOT2=$(cat .rootpath)
if [[ "$ROOT" != "$ROOT2" ]] ; then
echo "The directory you are requesting is from a different directory in the repo."
echo "This is not allowed."
echo "Your previous checkout(s) have been from ${ROOT2}"
echo "You are now requesting a checkout from ${ROOT}"
exit 1
fi
cd ..
else
mkdir trunk
cd trunk
echo "trunk" > .branchname
chmod 400 .branchname
echo "$ROOT" > .rootpath
chmod 400 .rootpath
cd ..
fi
if [[ "$1" == "sdt" ]] ; then
echo "Checking out /src"
checkout_dir "/src"
echo "Checking out /data"
checkout_dir "/data"
echo "Checking out /test"
checkout_dir "/test"
elif [[ "$1" == "all" ]] ; then
echo "Checking out /src"
checkout_dir "/src"
echo "Checking out /data"
checkout_dir "/data"
echo "Checking out /test"
checkout_dir "/test"
echo "Checking out /docs"
checkout_dir "/docs"
echo "Checking out /third_party"
checkout_dir "/third_party"
echo "Checking out /windowsbuild"
checkout_dir "/windowsbuild"
else
checkout_dir $1
fi
echo ""
echo "Your check out is ready"
echo "cd to the \"trunk\" directory to access the working copy"
echo ""
return 0
#!/bin/ksh
#
# Script: del_branch
#
# Purpose:
# Removes a branch.
#
# Programmer: Hank Childs
# Creation: May 10, 2007
#
# Modifications:
#
# *****************************************************************************
P=$(whence $0)
P2=${P%/*}
. ${P2}/visit_svn_helper
issueHelp="no"
if [[ $# != 1 ]] ; then
issueHelp="yes"
fi
if [[ $# == 1 ]] ; then
if [[ "$1" == "-help" || "$1" == "-h" || "$1" == "-?" ]] ; then
issueHelp="yes"
fi
fi
if [[ "$issueHelp" == "yes" ]] ; then
echo ""
echo "Usage: $0 <dir>"
echo ""
echo "Example: $0 bugfix"
echo "\tDeletes the branch ${VISIT_SVN_BRANCHES}/$SVN_NERSC_NAME/bugfix"
echo ""
exit 1
fi
TARGET=${VISIT_SVN_BRANCHES}/$SVN_NERSC_NAME/${1}
svn ls $TARGET 2>/dev/null > /dev/null
if [[ $? != 0 ]] ; then
echo "Branch ${TARGET} does not exist. No action will be taken."
exit 1
fi
stop="no"
while [[ "$stop" == "no" ]] ; do
echo "Are you sure you want to delete ${TARGET}? [yes/no]"
read answer
if [[ "$answer" == "yes" ]] ; then
stop="yes"
fi
if [[ "$answer" == "no" ]] ; then
stop="yes"
fi
done
if [[ "$answer" == "no" ]] ; then
echo "Aborting ... $TARGET will not be deleted"
exit 1
fi
svn delete $TARGET -m "Remove development branch $1"
if [[ $? == 0 ]] ; then
echo "Successfully deleted"
else
echo "There was an error with deleting the branch"
fi
exit 0
#!/bin/ksh
#
# Script: ls_branches
#
# Purpose:
# Lists the branches for a given developer or a given directory.
#
# Programmer: Hank Childs
# Creation: May 7, 2007
#
# Modifications:
#
# *****************************************************************************
if [[ $# != 0 ]] ; then
if [[ "$1" == "-help" || "$1" == "-h" || "$1" == "-?" ]] ; then
echo ""
echo "Usage: $0\t\t<prints branches with your username>"
echo "Usage: $0 <dir>\t<prints branches under REPO/branches/<dir>>"
echo ""
exit 1
fi
fi
P=$(whence $0)
P2=${P%/*}
. ${P2}/visit_svn_helper
if [[ $# != 0 ]] ; then
echo ""
svn ls ${VISIT_SVN_BRANCHES}/$1
echo ""
else
echo ""
echo "Top level branches:"
echo ""
svn ls ${VISIT_SVN_BRANCHES}
echo ""
echo ""
echo "Your branches:"
echo ""
svn ls ${VISIT_SVN_BRANCHES}/$SVN_NERSC_NAME
echo ""
fi
#!/bin/ksh
#
# Script: merge_branch_to_trunk
#
# Purpose:
# Merges a branch into the trunk
#
# Programmer: Hank Childs
# Creation: May 15, 2007
#
# Modifications:
#
# *****************************************************************************
issueHelp="no"
P=$(whence $0)
P2=${P%/*}
. ${P2}/visit_svn_helper
# Prevent print statements when changing directories
CDPATH=""
BRANCH=""
BRANCHNAME=""
if [[ $# != 1 ]] ; then
issueHelp="yes"
elif [[ "$1" == "-help" || "$1" == "-h" || "$1" == "-?" ]] ; then
issueHelp="yes"
elif [[ ! -f .branchname ]] ; then
echo "ERROR: You must run this script at the top of your checkout directory"
echo ""
issueHelp="yes"
elif [[ ! -f .rootpath ]] ; then
echo "ERROR: You must run this script at the top of your checkout directory"
echo ""
issueHelp="yes"
else
TRUNKNAME=$(cat .branchname)
if [[ "$TRUNKNAME" != "trunk" ]] ; then
echo "You must be in the trunk when you run this script"
echo ""
issueHelp="yes"
fi
WHOLE_TRUNK="yes"
ROOTPATH=$(cat .rootpath)
if [[ "$ROOTPATH" != "/" ]] ; then
WHOLE_TRUNK="no"
else
if [[ ! -d src || ! -d data || ! -d docs || ! -d test || ! -d third_party || ! -d windowsbuild ]] ; then
WHOLE_TRUNK="no"
fi
fi
if [[ "$WHOLE_TRUNK" == "no" ]]; then
echo "Your checkout is not of the entire trunk. The merge will only "
echo "take place over your checkout. If you continue, any changes that "
echo "are on directories not in your current checkout of the trunk will be lost!"
stop="no"
while [[ "$stop" == "no" ]] ; do
echo "Do you want to continue? [yes/no]"
read answer
if [[ "$answer" == "yes" ]] ; then
stop="yes"
fi
if [[ "$answer" == "no" ]] ; then
stop="yes"
fi
done
if [[ "$answer" == "no" ]] ; then
exit 1
fi
fi
BRANCHNAME=$1
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##*/} <branch>"
echo ""
echo "Example: ${0##*/} my_dev_work"
echo "\tshould be run at the top level of your checked out trunk. It will "
echo "\tmerge the work from my_dev_work into the trunk."
echo ""
exit 1
fi
echo ""
echo "Merging $BRANCH into the trunk"
echo ""
echo ""
echo "Getting record of last merge from this branch into the trunk..."
mkdir tmp_forRev$$
cd tmp_forRev$$
svn co ${VISIT_SVN_BRANCHES}/${SVN_NERSC_NAME}/${BRANCHNAME}/svninfo
cd svninfo
REV=$(cat Rev_toTrunk)
cd ../..
echo ""
echo "The revision of the last merge was $REV"
echo ""
for i in * ; do
if [[ -d $i && "$i" != "tmp_forRev$$" ]] ; then
cd $i
echo ""
echo "Merging directory \"$i\""
echo ""
svn merge -r ${REV}:HEAD ${VISIT_SVN_BRANCHES}/${SVN_NERSC_NAME}/${BRANCHNAME}/${ROOTPATH}/$i
NEW_REV_WITH_M=$(svnversion .)
NEW_REV=${NEW_REV_WITH_M%M}
cd ..
fi
done
cd tmp_forRev$$/svninfo
echo "$NEW_REV" > Rev_toTrunk
echo ""
echo "Updating branch $BRANCHNAME to contain a record of this merge"
echo ""
svn commit -m "Update for revision sent to trunk from $BRANCHNAME, $REV to $NEW_REV"
cd ../..
rm -Rf tmp_forRev$$
echo ""
echo "The changes from the branch $BRANCHNAME 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 into 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_branch_to_trunk_revision $BRANCHNAME $REV"
echo ""
return 0
#!/bin/ksh
#
# Script: merge_trunk_to_branch
#
# Purpose:
# Merges the trunk into a branch
#
# Programmer: Hank Childs
# Creation: May 14, 2007
#
# Modifications:
#
# *****************************************************************************
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##*/}"
echo "\tshould be run at the top level of your checked out branch. It will "
echo "\tuse the contents of the file \".branchname\" to determine which branch "
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 ""
NEW_REV_WITH_M="$REV"
for i in * ; do
if [[ -d $i && "$i" != "tmp_forRev$$" ]] ; then
cd $i
echo ""
echo "Merging directory \"$i\""
echo ""
svn merge -r ${REV}:HEAD ${VISIT_SVN_TRUNK}/${ROOTPATH}/$i
NEW_REV_WITH_M=$(svnversion .)
cd ..