Skip to content

Instantly share code, notes, and snippets.

@Discordanian
Created October 10, 2014 14:21
Show Gist options
  • Select an option

  • Save Discordanian/aacbc54cbfe529197c72 to your computer and use it in GitHub Desktop.

Select an option

Save Discordanian/aacbc54cbfe529197c72 to your computer and use it in GitHub Desktop.
Helpful Error Messages
#!/bin/sh
# First we are going to prompt for the branch name and the revision number.
# If those do not exist. Exit.
# If they do exist, Prompt first before proceeding.
# This has to be run from a full checkout of tdcs
TOPDIR=`dirname $0`
echo "cd to <$TOPDIR> to make sure we are in the correct directory."
cd $TOPDIR
echo
echo
echo
echo "What branch name do you want trunk to mirror?"
read BRANCH
echo
echo
echo
echo "What revision number to you want trunk to mirror?"
read REVISION
echo
echo
echo
echo "Are you sure that you want trunk to use https://subversion.company.com/svn/Node1/FOO/branches/$BRANCH -R $REVISION for trunk? (type 'YES' without the quotes)"
read REPLY
echo
echo
echo
if [ ! "$REPLY" == "YES" ]
then
echo "Come back when you are ready to pull the trigger."
echo
echo "Being a coward is probably for the best though."
echo
echo
exit 0
fi
MAXREV=`svn info https://subversion.company.com/svn/Node1/FOO/branches/$BRANCH |grep Revision |awk '{print $2}'`
echo "Compare $MAXREV with $REVISION"
if [ "$MAXREV" -lt "$REVISION" ]
then
echo "You do not know what you are doing. The max revision is $MAXREV and you want revision $REVISION."
echo
echo
echo
exit 0
fi
echo "Dropping existing trunk."
echo
echo
echo
# Blow away the existing trunk.
svn del trunk
svn ci trunk -m "Removing Trunk as part of a resync process."
if [ $? -ne 0 ]
then
echo "Something went wrong with removing the trunk. You probably have some reading to do to figure this out. Good luck!"
exit 0
fi
# Now make a 'branch' of trunk (weird eh?) based on the revision number and branch given above.
svn cp -r $REVISION https://subversion.company.com/svn/Node1/FOO/branches/$BRANCH https://subversion.company.com/svn/Node1/FOO/trunk -m "Trunk has been re-synced to branches/$BRANCH with revision $REVISION"
if [ $? -ne 0 ]
then
echo "Something went wrong with branching the trunk. You probably have some reading to do to figure this out. Good luck!"
exit 0
fi
svn up
if [ $? -ne 0 ]
then
echo "Something went wrong with updating your local repository. You probably have some reading to do to figure this out. Good luck!"
exit 0
fi
echo "\$Id: resync_trunk.sh 478 2013-08-06 20:30:15Z n620911 $"
echo "Resync Complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment