MSWSP: fix scope of VT_TYPE
[wireshark-wip.git] / tools / backport-rev
blob31dd38290c8b086afb1f2210c2a1c95d43c3001b
1 #!/bin/bash
3 # Copyrev - copies a revision from the Wireshark trunk to the current
4 # directory.
6 # Usage: backport-rev <svn revision>
8 # $Id$
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
28 VISUAL=$EDITOR
31 #Check if pbcopy (or similar) is available...
32 if [ `builtin type -p pbcopy` ] ; then
33 PBCOPY="pbcopy"
36 if [ `builtin type -p xsel` ] ; then
37 PBCOPY="xsel --clipboard --input"
40 if [ `builtin type -p putclip` ] ; then
41 PBCOPY="putclip"
44 if [ -z "$PBCOPY" ] ; then
45 echo "Can't find an clipboard copy. Check if pbcopy, xsel or putclip is installed in your system"
46 exit 1
48 function exit_err
50 if [ -n "$*" ] ; then
51 echo "$*"
53 echo -n $patchfile | $PBCOPY
54 echo "Patch saved to $patchfile and copied to pasteboard"
55 if [ -n "$VISUAL" ] ; then
56 "$VISUAL" $patchfile $logfile
57 else
58 echo "Can't find an editor. You'll have to open $patchfile and $logfile yourself."
60 exit 1
63 subdir=""
64 trunk="trunk"
66 while getopts "at:" opt ; do
67 case $opt in
69 subdir="/asn1"
72 trunk="trunk-$OPTARG"
74 \?)
75 echo "Unknown option -$OPTARG"
77 esac
78 done
79 shift $((OPTIND-1))
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"
90 rev="$1"
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
100 cd .$subdir
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
108 merge_err=0
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
112 merge_err=$?
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."
117 echo ""
118 cat $mergefile
119 rm $mergefile
120 echo ""
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"
124 echo ""
125 $dry_run_cmd < $patchfile
126 echo ""
127 exit_err "Giving up. You'll have to merge the patch yourself."
130 rm $mergefile
132 echo "OK"
133 echo "Attempting 'svn merge' live run:"
134 svn merge -c$rev $svnurl
136 if [ -n "$subdir" ] ; then
137 cd ..
139 echo Done with r$rev
141 echo "Copy over revisions from the trunk:"
142 echo ""
143 uniq < $logfile
145 rm -v $patchfile $logfile
148 # Editor modelines - http://www.wireshark.org/tools/modelines.html
150 # Local variables:
151 # c-basic-offset: 4
152 # tab-width: 8
153 # indent-tabs-mode: nil
154 # End:
156 # vi: set shiftwidth=4 tabstop=8 expandtab:
157 # :indentSize=4:tabSize=8:noTabs=true: