Warning, file /sdk/kde-dev-scripts/svnforwardport was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #!/bin/sh
0002 # Forwardport the last change in a branch to HEAD
0003 # Usage: svnforwardport <files>
0004 #
0005 # This is a port of the "cvsbackport" script:
0006 # Initial author: Dirk Mueller
0007 # Support for multiple command-line arguments, handling of patch rejects: David Faure
0008 # Ported to SVN: Till Gerken
0009 # Better usage, quote-safety: Matthew Woehlke
0010 #
0011 # This isn't the most sophisticated script ever, and might break. It needs to be
0012 # used from within the repository so that it can guess the remote URL correctly.
0013 #
0014 
0015 #REPOSITORY=https://svn.kde.org/home/kde
0016 
0017 usage() {
0018   echo "Usage: $0 <file> [<file> ...]"
0019   exit
0020 }
0021 
0022 while getopts 'h' opt ; do
0023   case $opt in
0024     *) usage;; # -h, --help will also trip this
0025   esac
0026 done
0027 unset opt
0028 shift `expr ${OPTIND} - 1`
0029 
0030 [ -z "$*" ] && usage
0031 
0032 export LC_ALL="C"
0033 
0034 SRC_REMOTE="`svn info | sed -n '/URL:/s/^URL: //p'`"
0035 BRANCH="`echo $SRC_REMOTE | sed 's|.*branches/KDE/\([^/]*\).*|\1|'`"
0036 TARGET_REMOTE=`echo $SRC_REMOTE | sed "s|branches/KDE/$BRANCH|trunk/KDE|"`
0037 
0038 echo "Forward porting from $BRANCH to trunk"
0039 TMPFILE="`mktemp svnforport.XXXXXX`" || exit 1
0040 
0041 patchok=1
0042 
0043 for file in "$@" ; do
0044 
0045   echo "Looking for last change to $file..."
0046   svnlastchange -ws "$file" > $TMPFILE || exit 1
0047   echo "Browsing last change to $file..."
0048   less "$TMPFILE"
0049 
0050   FILE_PATH="$file"
0051   FROM_URL="$SRC_REMOTE/$file"
0052   TO_URL="$TARGET_REMOTE/$file"
0053 
0054   echo "Switching to trunk..."
0055   svn switch "$TO_URL" "$FILE_PATH" || exit 1
0056   if patch "$FILE_PATH" "$TMPFILE"; then
0057     rm -f "$TMPFILE"
0058     echo "Showing diff for $file..."
0059     svn diff "$FILE_PATH" | less
0060   else
0061     rm -f "$TMPFILE"
0062     patchok=0
0063     break
0064   fi
0065 done
0066 
0067 if [ $patchok -eq 1 ]; then
0068   echo "Do you want to commit all changes? (y/n) [y]"
0069   read confirm
0070   if [ -z "$confirm" ] || [ "`echo $confirm | cut -c 1 | tr Y y`" = "y" ] ; then
0071     svn ci "$@"
0072   else
0073     echo "Aborted!" >&2
0074   fi
0075 else
0076   echo -n "Patch failed! Press enter to revert changes and switch back to branch: "
0077   read confirm
0078   for file in "$@" ; do
0079     svn revert "$file"
0080   done
0081 fi
0082 
0083 echo "Switching back to branch..."
0084 for file in "$@" ; do
0085   svn switch "$SRC_REMOTE/$file" "$file"
0086 done