Magellan Linux

Contents of /trunk/pkgtools/svn2cl-0.14/svn2cl.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3106 - (show annotations) (download) (as text)
Fri Mar 15 10:20:17 2019 UTC (5 years, 1 month ago) by niro
File MIME type: application/x-sh
File size: 12050 byte(s)
-added working svn2cl version
1 #!/bin/sh
2
3 # svn2cl.sh - front end shell script for svn2cl.xsl, calls xsltproc
4 # with the correct parameters
5 #
6 # Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Arthur de Jong
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
10 # are met:
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in
15 # the documentation and/or other materials provided with the
16 # distribution.
17 # 3. The name of the author may not be used to endorse or promote
18 # products derived from this software without specific prior
19 # written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
25 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
29 # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
31 # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 # exit on any failures
34 set -e
35 # report unset variables
36 set -u
37
38 # svn2cl version
39 VERSION="0.14"
40
41 # set default parameters
42 PWD=`pwd`
43 STRIPPREFIX="AUTOMATICALLY-DETERMINED"
44 LINELEN=75
45 GROUPBYDAY="no"
46 INCLUDEREV="no"
47 BREAKBEFOREMSG="no"
48 REPARAGRAPH="no"
49 SEPARATEDAYLOGS="no"
50 ACTIONS="no"
51 CHANGELOG=""
52 OUTSTYLE="cl"
53 SVNLOGCMD="svn --verbose --xml log"
54 SVNINFOCMD="svn --non-interactive info"
55 AUTHORSFILE=""
56 IGNORE_MESSAGE_STARTING=""
57 TITLE="ChangeLog"
58 REVISION_LINK="#r"
59 TICKET_LINK=""
60 TICKET_PREFIX="#"
61 TMPFILES=""
62 AWK="awk"
63
64 # do command line checking
65 prog=`basename "$0"`
66 while [ $# -gt 0 ]
67 do
68 case "$1" in
69 --strip-prefix)
70 STRIPPREFIX="$2"
71 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
72 ;;
73 --strip-prefix=*)
74 STRIPPREFIX=`echo "$1" | sed 's/^--[a-z-]*=//'`
75 shift
76 ;;
77 --linelen)
78 LINELEN="$2";
79 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
80 ;;
81 --linelen=*)
82 LINELEN=`echo "$1" | sed 's/^--[a-z-]*=//'`
83 shift
84 ;;
85 --group-by-day)
86 GROUPBYDAY="yes";
87 shift
88 ;;
89 --separate-daylogs)
90 SEPARATEDAYLOGS="yes"
91 shift
92 ;;
93 -i|--include-rev)
94 INCLUDEREV="yes";
95 shift
96 ;;
97 -a|--include-actions)
98 ACTIONS="yes"
99 shift
100 ;;
101 --break-before-msg|--breaks-before-msg)
102 # FIXME: if next argument is numeric use that as a parameter
103 BREAKBEFOREMSG="yes"
104 shift
105 ;;
106 --break-before-msg=*|--breaks-before-msg=*)
107 BREAKBEFOREMSG=`echo "$1" | sed 's/^--[a-z-]*=//'`
108 shift
109 ;;
110 --reparagraph)
111 REPARAGRAPH="yes"
112 shift
113 ;;
114 --title)
115 TITLE="$2"
116 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
117 ;;
118 --title=*)
119 TITLE=`echo "$1" | sed 's/^--[a-z-]*=//'`
120 shift
121 ;;
122 --revision-link)
123 REVISION_LINK="$2"
124 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
125 ;;
126 --revision-link=*)
127 REVISION_LINK=`echo "$1" | sed 's/^--[a-z-]*=//'`
128 shift
129 ;;
130 --ticket-link)
131 TICKET_LINK="$2"
132 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
133 ;;
134 --ticket-link=*)
135 TICKET_LINK=`echo "$1" | sed 's/^--[a-z-]*=//'`
136 shift
137 ;;
138 --ticket-prefix)
139 TICKET_PREFIX="$2"
140 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
141 ;;
142 --ticket-prefix=*)
143 TICKET_PREFIX=`echo "$1" | sed 's/^--[a-z-]*=//'`
144 shift
145 ;;
146 --ignore-message-starting)
147 IGNORE_MESSAGE_STARTING="$2"
148 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
149 ;;
150 --ignore-message-starting=*)
151 IGNORE_MESSAGE_STARTING=`echo "$1" | sed 's/^--[a-z-]*=//'`
152 shift
153 ;;
154 -f|--file|-o|--output)
155 CHANGELOG="$2"
156 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
157 ;;
158 --file=*|--output=*)
159 CHANGELOG=`echo "$1" | sed 's/^--[a-z-]*=//'`
160 shift
161 ;;
162 --stdout)
163 CHANGELOG="-"
164 shift
165 ;;
166 --authors)
167 AUTHORSFILE="$2"
168 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
169 ;;
170 --authors=*)
171 AUTHORSFILE=`echo "$1" | sed 's/^--[a-z-]*=//'`
172 shift
173 ;;
174 --html)
175 OUTSTYLE="html"
176 shift
177 ;;
178 -r|--revision|-c|--change|--targets|-l|--limit)
179 # add these as extra options to the log command (with argument)
180 arg=`echo "$2" | sed "s/'/'\"'\"'/g"`
181 SVNLOGCMD="$SVNLOGCMD $1 '$arg'"
182 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
183 ;;
184 --revision=*|--change=*|--targets=*|--limit=*)
185 # these are single argument versions of the above (with argument)
186 arg=`echo "$1" | sed "s/'/'\"'\"'/g"`
187 SVNLOGCMD="$SVNLOGCMD '$arg'"
188 shift
189 ;;
190 --username|--password|--config-dir|--config-option)
191 # add these as extra options to the log and info commands (with argument)
192 arg=`echo "$2" | sed "s/'/'\"'\"'/g"`
193 SVNLOGCMD="$SVNLOGCMD $1 '$arg'"
194 SVNINFOCMD="$SVNINFOCMD $1 '$arg'"
195 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
196 ;;
197 --username=*|--password=*|--config-dir=*|--config-option=*)
198 # these are single argument versions of the above (with argument)
199 arg=`echo "$1" | sed "s/'/'\"'\"'/g"`
200 SVNLOGCMD="$SVNLOGCMD '$arg'"
201 SVNINFOCMD="$SVNINFOCMD '$arg'"
202 shift
203 ;;
204 -g|--use-merge-history|--stop-on-copy)
205 # add these as simple options to the log command
206 SVNLOGCMD="$SVNLOGCMD $1"
207 shift
208 ;;
209 --no-auth-cache|--non-interactive|--trust-server-cert)
210 # add these as simple options to both the log and info commands
211 SVNLOGCMD="$SVNLOGCMD $1"
212 SVNINFOCMD="$SVNINFOCMD $1"
213 shift
214 ;;
215 -V|--version)
216 echo "$prog $VERSION";
217 echo "Written by Arthur de Jong."
218 echo ""
219 echo "Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Arthur de Jong."
220 echo "This is free software; see the source for copying conditions. There is NO"
221 echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
222 exit 0
223 ;;
224 -h|--help)
225 echo "Usage: $prog [OPTION]... [PATH]..."
226 echo "Generate a ChangeLog from a subversion repository."
227 echo ""
228 echo " --strip-prefix=NAME prefix to strip from all entries, defaults path"
229 echo " inside the repository"
230 echo " --linelen=NUM maximum length of an output line"
231 echo " --group-by-day group changelog entries by day"
232 echo " --separate-daylogs put a blank line between grouped by day entries"
233 echo " -i, --include-rev include revision numbers"
234 echo " -a, --include-actions add [ADD], [DEL] and [CPY] tags to files"
235 echo " --break-before-msg[=NUM] add a line break (or multiple breaks)"
236 echo " between the paths and the log message"
237 echo " --reparagraph rewrap lines inside a paragraph"
238 echo " --title=NAME title used in html file"
239 echo " --revision-link=NAME link revision numbers in html output"
240 echo " --ticket-link=NAME change #foo strings to links"
241 echo " --ignore-message-starting=STRING"
242 echo " ignore messages starting with the string"
243 echo " -o, --output=FILE output to FILE instead of ChangeLog"
244 echo " -f, --file=FILE alias for -o, --output"
245 echo " --stdout output to stdout instead of ChangeLog"
246 echo " --authors=FILE file to read for authors"
247 echo " --html output as html instead of plain text"
248 echo " -h, --help display this help and exit"
249 echo " -V, --version output version information and exit"
250 echo ""
251 echo "PATH arguments and the following options are passed to the svn log"
252 echo "command: -r, --revision, -g, --use-merge-history, -c, --change,"
253 echo "--targets, --stop-on-copy, -l, --username, --password, --no-auth-cache,"
254 echo "--non-interactive, --trust-server-cert, --config-dir and --config-option"
255 echo "(see 'svn help log' for more information)."
256 exit 0
257 ;;
258 -*)
259 echo "$prog: invalid option -- $1"
260 echo "Try '$prog --help' for more information."
261 exit 1
262 ;;
263 *)
264 arg=`echo "$1" | sed "s/'/'\"'\"'/g"`
265 SVNLOGCMD="$SVNLOGCMD '$arg'"
266 SVNINFOCMD="$SVNINFOCMD '$arg'"
267 shift
268 ;;
269 esac
270 done
271
272 # find the directory that this script resides in
273 prog="$0"
274 while [ -h "$prog" ]
275 do
276 dir=`dirname "$prog"`
277 prog=`ls -ld "$prog" | sed "s/^.*-> \(.*\)/\1/;/^[^/]/s,^,$dir/,"`
278 done
279 dir=`dirname "$prog"`
280 dir=`cd "$dir" && pwd`
281 XSL="$dir/svn2${OUTSTYLE}.xsl"
282
283 # check if the authors file is formatted as a legacy
284 # colon separated file
285 if [ -n "$AUTHORSFILE" ] && \
286 egrep '^(#.*|[a-zA-Z0-9].*:)' "$AUTHORSFILE" > /dev/null 2>/dev/null
287 then
288 # create a temporary file
289 tmpfile=`mktemp -t svn2cl.XXXXXX 2> /dev/null || tempfile -s .svn2cl 2> /dev/null || echo "$AUTHORSFILE.$$.xml"`
290 arg=`echo "$tmpfile" | sed "s/'/'\"'\"'/g"`
291 TMPFILES="$TMPFILES '$arg'"
292 # generate an authors.xml file on the fly
293 echo '<authors>' > "$tmpfile"
294 sed -n 's/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g;s|^\([a-zA-Z0-9][^:]*\):\(.*\)$| <author uid="\1">\2</author>|p' \
295 < "$AUTHORSFILE" >> "$tmpfile"
296 echo '</authors>' >> "$tmpfile"
297 AUTHORSFILE="$tmpfile"
298 fi
299
300 # find the absolute path of the authors file
301 # (otherwise xsltproc will find the file relative to svn2cl.xsl)
302 pwd=`pwd`
303 AUTHORSFILE=`echo "$AUTHORSFILE" | sed "/^[^/]/s|^|$pwd/|"`
304
305 # if no filename was specified, make one up
306 if [ -z "$CHANGELOG" ]
307 then
308 CHANGELOG="ChangeLog"
309 if [ "$OUTSTYLE" != "cl" ]
310 then
311 CHANGELOG="$CHANGELOG.$OUTSTYLE"
312 fi
313 fi
314
315 # try to determin a prefix to strip from all paths
316 if [ "$STRIPPREFIX" = "AUTOMATICALLY-DETERMINED" ]
317 then
318 STRIPPREFIX=`LANG=C eval "$SVNINFOCMD" | $AWK '/^URL:/{url=$2} /^Repository Root:/{root=$3} END{if(root){print substr(url,length(root)+2)}else{n=split(url,u,"/");print u[n]}}'`
319 STRIPPREFIX=`echo "$STRIPPREFIX" | sed 's/%20/ /g'`
320 fi
321
322 # redirect stdout to the changelog file if needed
323 if [ "x$CHANGELOG" != "x-" ]
324 then
325 exec > "$CHANGELOG"
326 fi
327
328 # actually run the command we need
329 eval "$SVNLOGCMD" | \
330 xsltproc --stringparam strip-prefix "$STRIPPREFIX" \
331 --stringparam linelen "$LINELEN" \
332 --stringparam groupbyday "$GROUPBYDAY" \
333 --stringparam separate-daylogs "$SEPARATEDAYLOGS" \
334 --stringparam include-rev "$INCLUDEREV" \
335 --stringparam include-actions "$ACTIONS" \
336 --stringparam breakbeforemsg "$BREAKBEFOREMSG" \
337 --stringparam reparagraph "$REPARAGRAPH" \
338 --stringparam authorsfile "$AUTHORSFILE" \
339 --stringparam title "$TITLE" \
340 --stringparam revision-link "$REVISION_LINK" \
341 --stringparam ticket-link "$TICKET_LINK" \
342 --stringparam ticket-prefix "$TICKET_PREFIX" \
343 --stringparam ignore-message-starting "$IGNORE_MESSAGE_STARTING" \
344 --nowrite \
345 --nomkdir \
346 --nonet \
347 "$XSL" -
348
349 # clean up temporary files
350 [ -n "$TMPFILES" ] && eval "rm -f $TMPFILES"
351
352 # we're done (the previous command could return false)
353 exit 0

Properties

Name Value
svn:executable *