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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/bin/sh
# Forwardport the last change in a branch to HEAD
# Usage: svnforwardport <files>
#
# This is a port of the "cvsbackport" script:
# Initial author: Dirk Mueller
# Support for multiple command-line arguments, handling of patch rejects: David Faure
# Ported to SVN: Till Gerken
# Better usage, quote-safety: Matthew Woehlke
#
# This isn't the most sophisticated script ever, and might break. 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
usage() {
echo "Usage: $0 <file> [<file> ...]"
exit
}
while getopts '-:h' opt ; do
case $opt in
*) usage;; # -h, --help will also trip this
esac
done
unset opt
shift `expr ${OPTIND} - 1`
[ -z "$*" ] && usage
export LC_ALL="C"
SRC_REMOTE="`svn info | sed -n '/URL:/s/^URL: //p'`"
BRANCH="`echo $SRC_REMOTE | sed 's|.*branches/KDE/\([^/]*\).*|\1|'`"
TARGET_REMOTE=`echo $SRC_REMOTE | sed "s|branches/KDE/$BRANCH|trunk/KDE|"`
echo "Forward porting from $BRANCH to trunk"
TMPFILE="`mktemp svnforport.XXXXXX`" || exit 1
patchok=1
for file in "$@" ; do
echo "Looking for last change to $file..."
svnlastchange -ws "$file" > $TMPFILE || exit 1
echo "Browsing last change to $file..."
less "$TMPFILE"
FILE_PATH="$file"
FROM_URL="$SRC_REMOTE/$file"
TO_URL="$TARGET_REMOTE/$file"
echo "Switching to trunk..."
svn switch "$TO_URL" "$FILE_PATH" || exit 1
if patch "$FILE_PATH" "$TMPFILE"; then
rm -f "$TMPFILE"
echo "Showing diff for $file..."
svn diff "$FILE_PATH" | less
else
rm -f "$TMPFILE"
patchok=0
break
fi
done
if [ $patchok -eq 1 ]; then
echo "Do you want to commit all changes? (y/n) [y]"
read confirm
if [ -z "$confirm" ] || [ "`echo $confirm | cut -c 1 | tr Y y`" = "y" ] ; then
svn ci "$@"
else
echo "Aborted!" >&2
fi
else
echo -n "Patch failed! Press enter to revert changes and switch back to branch: "
read confirm
for file in "$@" ; do
svn revert "$file"
done
fi
echo "Switching back to branch..."
for file in "$@" ; do
svn switch "$SRC_REMOTE/$file" "$file"
done
|