/[path-sandbox]/trunk/scripts/svn2cl
Gentoo

Contents of /trunk/scripts/svn2cl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 374 - (show annotations) (download)
Sun Nov 9 10:46:45 2008 UTC (5 years, 5 months ago) by vapier
File size: 10698 byte(s)
update svn2cl to 0.9
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 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.9"
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 CHANGELOG=""
51 OUTSTYLE="cl"
52 SVNLOGCMD="svn --verbose --xml log"
53 SVNINFOCMD="svn info"
54 AUTHORSFILE=""
55 IGNORE_MESSAGE_STARTING=""
56 TITLE="ChangeLog"
57 REVISION_LINK="#r"
58 TMPFILES=""
59
60 # do command line checking
61 prog=`basename $0`
62 while [ $# -gt 0 ]
63 do
64 case "$1" in
65 --strip-prefix)
66 STRIPPREFIX="$2"
67 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
68 ;;
69 --strip-prefix=*)
70 STRIPPREFIX=`echo "$1" | sed 's/^--[a-z-]*=//'`
71 shift
72 ;;
73 --linelen)
74 LINELEN="$2";
75 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
76 ;;
77 --linelen=*)
78 LINELEN=`echo "$1" | sed 's/^--[a-z-]*=//'`
79 shift
80 ;;
81 --group-by-day)
82 GROUPBYDAY="yes";
83 shift
84 ;;
85 --separate-daylogs)
86 SEPARATEDAYLOGS="yes"
87 shift
88 ;;
89 -i|--include-rev)
90 INCLUDEREV="yes";
91 shift
92 ;;
93 --break-before-msg|--breaks-before-msg)
94 # FIXME: if next argument is numeric use that as a parameter
95 BREAKBEFOREMSG="yes"
96 shift
97 ;;
98 --break-before-msg=*|--breaks-before-msg=*)
99 BREAKBEFOREMSG=`echo "$1" | sed 's/^--[a-z-]*=//'`
100 shift
101 ;;
102 --reparagraph)
103 REPARAGRAPH="yes"
104 shift
105 ;;
106 --title)
107 TITLE="$2"
108 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
109 ;;
110 --title=*)
111 TITLE=`echo "$1" | sed 's/^--[a-z-]*=//'`
112 shift
113 ;;
114 --revision-link)
115 REVISION_LINK="$2"
116 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
117 ;;
118 --revision-link=*)
119 REVISION_LINK=`echo "$1" | sed 's/^--[a-z-]*=//'`
120 shift
121 ;;
122 --ignore-message-starting)
123 IGNORE_MESSAGE_STARTING="$2"
124 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
125 ;;
126 --ignore-message-starting=*)
127 IGNORE_MESSAGE_STARTING=`echo "$1" | sed 's/^--[a-z-]*=//'`
128 shift
129 ;;
130 -f|--file|-o|--output)
131 CHANGELOG="$2"
132 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
133 ;;
134 --file=*|--output=*)
135 CHANGELOG=`echo "$1" | sed 's/^--[a-z-]*=//'`
136 shift
137 ;;
138 --stdout)
139 CHANGELOG="-"
140 shift
141 ;;
142 --authors)
143 AUTHORSFILE="$2"
144 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
145 ;;
146 --authors=*)
147 AUTHORSFILE=`echo "$1" | sed 's/^--[a-z-]*=//'`
148 shift
149 ;;
150 --html)
151 OUTSTYLE="html"
152 shift
153 ;;
154 -r|--revision|--targets|--limit)
155 # add these as extra options to the command (with argument)
156 arg=`echo "$2" | sed "s/'/'\"'\"'/g"`
157 SVNLOGCMD="$SVNLOGCMD $1 '$arg'"
158 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
159 ;;
160 --username|--password|--config-dir)
161 # add these as extra options to the command (with argument)
162 arg=`echo "$2" | sed "s/'/'\"'\"'/g"`
163 SVNLOGCMD="$SVNLOGCMD $1 '$arg'"
164 # also add to svn info command
165 SVNINFOCMD="$SVNINFOCMD $1 '$arg'"
166 shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
167 ;;
168 --revision=*|--targets=*|--limit=*)
169 # these are single argument versions of the above
170 arg=`echo "$1" | sed "s/'/'\"'\"'/g"`
171 SVNLOGCMD="$SVNLOGCMD '$arg'"
172 shift
173 ;;
174 --username=*|--password=*|--config-dir=*)
175 # these are single argument versions of the above
176 arg=`echo "$1" | sed "s/'/'\"'\"'/g"`
177 SVNLOGCMD="$SVNLOGCMD '$arg'"
178 # also add to svn info command
179 SVNINFOCMD="$SVNINFOCMD '$arg'"
180 shift
181 ;;
182 --stop-on-copy)
183 # add these as simple options
184 SVNLOGCMD="$SVNLOGCMD $1"
185 shift
186 ;;
187 --no-auth-cache|--non-interactive)
188 # add these as simple options
189 SVNLOGCMD="$SVNLOGCMD $1"
190 # also add to svn info command
191 SVNINFOCMD="$SVNINFOCMD $1"
192 shift
193 ;;
194 -V|--version)
195 echo "$prog $VERSION";
196 echo "Written by Arthur de Jong."
197 echo ""
198 echo "Copyright (C) 2005, 2006, 2007 Arthur de Jong."
199 echo "This is free software; see the source for copying conditions. There is NO"
200 echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
201 exit 0
202 ;;
203 -h|--help)
204 echo "Usage: $prog [OPTION]... [PATH]..."
205 echo "Generate a ChangeLog from a subversion repository."
206 echo ""
207 echo " --strip-prefix=NAME prefix to strip from all entries, defaults"
208 echo " path inside the repository"
209 echo " --linelen=NUM maximum length of an output line"
210 echo " --group-by-day group changelog entries by day"
211 echo " --separate-daylogs put a blank line between grouped by day entries"
212 echo " -i, --include-rev include revision numbers"
213 echo " --break-before-msg[=NUM] add a line break (or multiple breaks)"
214 echo " between the paths and the log message"
215 echo " --reparagraph rewrap lines inside a paragraph"
216 echo " --title=NAME title used in html file"
217 echo " --revision-link=NAME link revision numbers in html output"
218 echo " --ignore-message-starting=STRING"
219 echo " ignore messages starting with the string"
220 echo " -o, --output=FILE output to FILE instead of ChangeLog"
221 echo " -f, --file=FILE alias for -o, --output"
222 echo " --stdout output to stdout instead of ChangeLog"
223 echo " --authors=FILE file to read for authors"
224 echo " --html output as html instead of plain text"
225 echo " -h, --help display this help and exit"
226 echo " -V, --version output version information and exit"
227 echo ""
228 echo "PATH arguments and the following options are passed to the svn log"
229 echo "command: -r, --revision, --targets --stop-on-copy, --username,"
230 echo "--password, --no-auth-cache, --non-interactive, --config-dir and"
231 echo "--limit (see \`svn help log' for more information)."
232 exit 0
233 ;;
234 -*)
235 echo "$prog: invalid option -- $1"
236 echo "Try \`$prog --help' for more information."
237 exit 1
238 ;;
239 *)
240 arg=`echo "$1" | sed "s/'/'\"'\"'/g"`
241 SVNLOGCMD="$SVNLOGCMD '$arg'"
242 SVNINFOCMD="$SVNINFOCMD '$arg'"
243 shift
244 ;;
245 esac
246 done
247
248 XSL="/usr/share/svn2cl/svn2${OUTSTYLE}.xsl"
249
250 # check if the authors file is formatted as a legacy
251 # colon separated file
252 if [ -n "$AUTHORSFILE" ] && \
253 egrep '^(#.*|[a-zA-Z0-9].*:)' "$AUTHORSFILE" > /dev/null 2>/dev/null
254 then
255 # create a temporary file
256 tmpfile=`mktemp -t svn2cl.XXXXXX 2> /dev/null || tempfile -s .svn2cl 2> /dev/null || echo "$AUTHORSFILE.$$.xml"`
257 arg=`echo "$tmpfile" | sed "s/'/'\"'\"'/g"`
258 TMPFILES="$TMPFILES '$arg'"
259 # generate an authors.xml file on the fly
260 echo '<authors>' > "$tmpfile"
261 sed -n 's/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g;s|^\([a-zA-Z0-9][^:]*\):\(.*\)$| <author uid="\1">\2</author>|p' \
262 < "$AUTHORSFILE" >> "$tmpfile"
263 echo '</authors>' >> "$tmpfile"
264 AUTHORSFILE="$tmpfile"
265 fi
266
267 # find the absolute path of the authors file
268 # (otherwise xsltproc will find the file relative to svn2cl.xsl)
269 pwd=`pwd`
270 AUTHORSFILE=`echo "$AUTHORSFILE" | sed "/^[^/]/s|^|$pwd/|"`
271
272 # if no filename was specified, make one up
273 if [ -z "$CHANGELOG" ]
274 then
275 CHANGELOG="ChangeLog"
276 [ "$OUTSTYLE" != "cl" ] && CHANGELOG="$CHANGELOG.$OUTSTYLE"
277 fi
278
279 # try to determin a prefix to strip from all paths
280 if [ "$STRIPPREFIX" = "AUTOMATICALLY-DETERMINED" ]
281 then
282 STRIPPREFIX=`LANG=C eval "$SVNINFOCMD" 2> /dev/null | awk '/^URL:/{url=$2} /^Repository Root:/{root=$3} END{if(root){print substr(url,length(root)+2)}else{gsub("^.*/","",url);print url}}'`
283 STRIPPREFIX=`echo "$STRIPPREFIX" | sed 's/%20/ /g'`
284 fi
285
286 # redirect stdout to the changelog file if needed
287 if [ "x$CHANGELOG" != "x-" ]
288 then
289 exec > "$CHANGELOG"
290 fi
291
292 # actually run the command we need
293 eval "$SVNLOGCMD" | \
294 xsltproc --stringparam strip-prefix "$STRIPPREFIX" \
295 --stringparam linelen "$LINELEN" \
296 --stringparam groupbyday "$GROUPBYDAY" \
297 --stringparam separate-daylogs "$SEPARATEDAYLOGS" \
298 --stringparam include-rev "$INCLUDEREV" \
299 --stringparam breakbeforemsg "$BREAKBEFOREMSG" \
300 --stringparam reparagraph "$REPARAGRAPH" \
301 --stringparam authorsfile "$AUTHORSFILE" \
302 --stringparam title "$TITLE" \
303 --stringparam revision-link "$REVISION_LINK" \
304 --stringparam ignore-message-starting "$IGNORE_MESSAGE_STARTING" \
305 --nowrite \
306 --nomkdir \
307 --nonet \
308 "$XSL" -
309
310 # clean up temporary files
311 [ -n "$TMPFILES" ] && eval "rm -f $TMPFILES"
312
313 # we're done (the previous command could return false)
314 exit 0

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20