File indexing completed on 2025-02-02 05:31:55
0001 #!/bin/sh 0002 # Backport the last change in HEAD, to a branch. 0003 # Usage: svnbackport [-b branch] <file> [<file> ...] 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 # Options and 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: $(basename $0) [-b <branch>] [-r <revision number>] <file> [<file> ...]" 0019 echo " default branch is $DEF_BRANCH" 0020 exit 0021 } 0022 0023 DEF_BRANCH=4.9 0024 BRANCH=$DEF_BRANCH 0025 0026 while getopts 'b:r:-:h' opt ; do 0027 case $opt in 0028 b) BRANCH="$OPTARG";; 0029 r) REV="-r $OPTARG";; 0030 *) usage;; # -h, --help will also trip this 0031 esac 0032 done 0033 unset opt 0034 shift `expr ${OPTIND} - 1` 0035 0036 [ -z "$*" ] && usage 0037 0038 export LC_ALL="C" 0039 0040 SRC_REMOTE="`svn info | sed -n '/URL:/s/^URL: //p'`" 0041 TARGET_REMOTE="`echo $SRC_REMOTE | sed "s|trunk/KDE|branches/KDE/$BRANCH|"`" 0042 0043 echo "Backporting to $BRANCH" 0044 TMPFILE=`mktemp svnbackport.XXXXXX` || exit 1 0045 0046 patchok=1 0047 0048 for file in "$@" ; do 0049 0050 echo "Looking for last change to $file..." 0051 svnlastchange -ws $REV "$file" > $TMPFILE || exit 1 0052 echo "Browsing last change to $file..." 0053 less "$TMPFILE" 0054 0055 FILE_PATH="$file" 0056 FROM_URL="$SRC_REMOTE/$file" 0057 TO_URL="$TARGET_REMOTE/$file" 0058 0059 echo "Switching to branch..." 0060 svn switch "$TO_URL" "$FILE_PATH" || exit 1 0061 if patch "$FILE_PATH" "$TMPFILE"; then 0062 rm -f "$TMPFILE" 0063 echo "Showing diff for $file..." 0064 svn diff "$FILE_PATH" | less 0065 else 0066 rm -f "$TMPFILE" 0067 patchok=0 0068 break 0069 fi 0070 done 0071 0072 if [ $patchok -eq 1 ]; then 0073 echo "Do you want to commit all changes? (y/n) [y]" 0074 read confirm 0075 if [ -z "$confirm" ] || [ "`echo $confirm | cut -c 1 | tr Y y`" = "y" ] ; then 0076 svn ci "$@" 0077 else 0078 echo "Aborted!" >&2 0079 fi 0080 else 0081 echo -n "Patch failed! Press enter to revert changes and switch back to trunk: " 0082 read confirm 0083 for file in "$@" ; do 0084 svn revert "$file" 0085 done 0086 fi 0087 0088 echo "Switching back to trunk..." 0089 for file in "$@" ; do 0090 svn switch "$SRC_REMOTE/$file" "$file" 0091 done