#!/bin/sh # # ========================================================================= # File: svn-merge # # Copyright (c) 2005 and onwards, Josh Glover # # LICENCE: # # This file is distributed under the terms of the BSD License (version # 2). See the COPYING file, which should have been distributed with this # file, for details. If you did not receive the COPYING file, see: # # http://www.jmglov.net/opensource/licenses/bsd.txt # # DESCRIPTION: # # Merges all changes from one or more revisions from a branch to the # current working directory in the working copy. # # USAGE: # # svn-merge {} # # EXAMPLES: # # *** # # DEPENDENCIES: # # Awk # /bin/sh # grep # Subversion # # MODIFICATIONS: # # Josh Glover (2005/03/29): Initial revision # ========================================================================= repos="$1"; shift branch="$1"; shift pre_msg="$1"; shift # Validate params if test -z "$1"; then echo 'Usage: '"$0"' {}' 1>&2 exit 255 fi # Iterate over revisions while test -n "$1"; do rev=$1; shift let "prev = rev - 1" echo echo "Merging revision ${rev} from ${branch}" echo "svn merge -r $prev:$rev ${repos}/${branch}" svn merge -r $prev:$rev "${repos}/${branch}" || exit $? echo echo 'Current status:' svn stat -u echo "svn commit -m '${pre_msg} merged in from ${branch} (-r $prev:$rev)'" echo -n "Commit OK? (y/n) " read prompt echo "${prompt}" | grep -i '^y$' >/dev/null 2>&1 retval=$? # Skip to the next iteration unless the user answered in the affirmative if test ${retval} -ne 0; then echo 1>&2 echo 'Aborted! You will probably want to run "svn revert" to clean up' \ 1>&2 exit 1 fi # If control reaches here, go ahead with the commit svn commit -m "${pre_msg} merged in from ${branch} (-r $prev:$rev)" \ || exit $? done # while (generating patches)