summaryrefslogtreecommitdiffstats
path: root/scripts/svnbackport
blob: cdecdcb4e6f7d582ed9f53f016ef130844f0890e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
# Backport the last change in HEAD, to a branch.
# Usage: svnbackport <files>
# WARNING: the branch tag is hardcoded into the script, make sure to check it!
#
# This is a port of the "cvsbackport" script:
# Initial author: Dirk Mueller
# Support for multiple command-line arguments: David Faure
# Ported to SVN: Till Gerken
# Help message: Thomas Zander
#
# It is a straight port and not very sophisticated. It might break. I hope
# that someone else with more knowledge about Subversion will pick it up.
# It needs to be used from within the repository so that it can guess
# the remote URL correctly.
#

#REPOSITORY=https://svn.kde.org/home/kde

if test -z "$1" -o "$1" = "-h" -o "$1" = "--help"; then
    echo "Usage: svnbackport recentlyCommittedFile";
    exit;
fi

BRANCH=3.5

SRC_REMOTE=`svn info | grep URL: | cut -c6-`
TARGET_REMOTE=`echo $SRC_REMOTE | sed "s|trunk/KDE|branches/KDE/$BRANCH|"`


echo "Backporting to $BRANCH"
TMPFILE=`mktemp svnbackport.XXXXXX` || exit 1
files=$*
until test $# -eq 0; do

  echo "looking for last change to $1..."
  svnlastchange $1 > $TMPFILE
  echo "browsing last change to $1..."
  less $TMPFILE

  FILE_PATH=$1
  FROM_URL=$SRC_REMOTE/$1
  TO_URL=$TARGET_REMOTE/$1

  echo "switching to branch..."
  svn switch $TO_URL $FILE_PATH
  patch $FILE_PATH $TMPFILE
  rm -f $TMPFILE
  echo "showing diff for $1..."
  svn diff $FILE_PATH | less

  shift
done

kdialog --yesno "Do you want to commit all changes?"
if [ $? = 0 ]; then
  svn ci $files
fi

echo "switching back to trunk..."
for file in $files
do
  svn switch $SRC_REMOTE/$file $file
done