3 # Copyrev - copies a revision from the Wireshark trunk to the current
6 # Usage: backport-rev <svn revision>
10 # Copyright 2013 Gerald Combs
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 2
15 # of the License, or (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 if [ -z "$VISUAL" ] ; then
31 #Check if pbcopy (or similar) is available...
32 if [ `builtin type -p pbcopy` ] ; then
36 if [ `builtin type -p xsel` ] ; then
37 PBCOPY
="xsel --clipboard --input"
40 if [ `builtin type -p putclip` ] ; then
44 if [ -z "$PBCOPY" ] ; then
45 echo "Can't find an clipboard copy. Check if pbcopy, xsel or putclip is installed in your system"
53 echo -n $patchfile |
$PBCOPY
54 echo "Patch saved to $patchfile and copied to pasteboard"
55 if [ -n "$VISUAL" ] ; then
56 "$VISUAL" $patchfile $logfile
58 echo "Can't find an editor. You'll have to open $patchfile and $logfile yourself."
66 while getopts "at:" opt
; do
75 echo "Unknown option -$OPTARG"
81 svninfo
="`svn info | grep ^URL | cut -f2 -d' '`"
82 if [ -z "$svninfo" ] ; then
83 exit_err
"Can't find repository information. Are you running this from a Wireshark SVN directory?"
86 svnurl
=`dirname $svninfo`
87 svnurl
="$svnurl/$trunk"
88 #svnurl="$HOME/Development/wireshark"
92 patchfile
="/tmp/backport-rev-$rev.patch"
93 logfile
="/tmp/backport-rev-$rev.log"
94 mergefile
="/tmp/backport-rev-$rev.merge"
95 oldrev
=$
(( $rev - 1 ))
96 echo "Working on r$rev ($oldrev)"
98 echo -n "Attempting 'svn merge' dry run. "
99 if [ -n "$subdir" ] ; then
103 svn
diff --diff-cmd /usr
/bin
/diff -x "-w -b -U 5" -c $rev $svnurl$subdir \
104 > $patchfile || exit_err
"Error"
106 svn log
-v -r $rev $svnurl |
sed -e 's/^..*/ &/' > $logfile ||
exit 1
109 # Some versions of svn always return 0. Check the return value then look
110 # for a "Summary of conflicts" line.
111 svn merge
--dry-run -c$rev $svnurl > $mergefile 2>&1
113 grep '^Summary' $mergefile > /dev
/null
2>&1 && merge_err
=1
115 if [ $merge_err -ne 0 ] ; then
116 echo "Error. Dry run output follows."
121 dry_run_cmd
="patch --batch --ignore-whitespace --strip=0 --dry-run"
122 echo "Merge failed. Trying 'patch' dry run:"
123 echo " $dry_run_cmd < $patchfile"
125 $dry_run_cmd < $patchfile
127 exit_err
"Giving up. You'll have to merge the patch yourself."
133 echo "Attempting 'svn merge' live run:"
134 svn merge
-c$rev $svnurl
136 if [ -n "$subdir" ] ; then
141 echo "Copy over revisions from the trunk:"
145 rm -v $patchfile $logfile
148 # Editor modelines - http://www.wireshark.org/tools/modelines.html
153 # indent-tabs-mode: nil
156 # vi: set shiftwidth=4 tabstop=8 expandtab:
157 # :indentSize=4:tabSize=8:noTabs=true: