Mercurial > hg > buildtools
comparison hg2cl @ 2:4cf32ca7b15e
Added very preliminary version of hg2cl (requires svn2cl.xsl) which
generates ChangeLog from Mercurial repository.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 09 May 2008 14:13:10 +0300 |
parents | |
children | f27514832835 |
comparison
equal
deleted
inserted
replaced
1:2375efb3340d | 2:4cf32ca7b15e |
---|---|
1 #!/bin/sh | |
2 | |
3 # hg2cl.sh - front end shell script for svn2cl.xsl, calls xsltproc | |
4 # with the correct parameters | |
5 # | |
6 # Copyright (C) 2005 Arthur de Jong. | |
7 # Copyright (C) 2008 Matti Hamalainen | |
8 # | |
9 # Redistribution and use in source and binary forms, with or without | |
10 # modification, are permitted provided that the following conditions | |
11 # are met: | |
12 # 1. Redistributions of source code must retain the above copyright | |
13 # notice, this list of conditions and the following disclaimer. | |
14 # 2. Redistributions in binary form must reproduce the above copyright | |
15 # notice, this list of conditions and the following disclaimer in | |
16 # the documentation and/or other materials provided with the | |
17 # distribution. | |
18 # 3. The name of the author may not be used to endorse or promote | |
19 # products derived from this software without specific prior | |
20 # written permission. | |
21 # | |
22 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
23 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
24 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
25 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | |
26 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
27 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | |
28 # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
29 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | |
30 # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |
31 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | |
32 # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
33 | |
34 # exit on any failures | |
35 set -e | |
36 | |
37 # svn2cl version | |
38 VERSION="0.2" | |
39 | |
40 # set default parameters | |
41 STRIPPREFIX=`basename $(pwd)` | |
42 LINELEN=75 | |
43 GROUPBYDAY="yes" | |
44 INCLUDEREV="no" | |
45 CHANGELOG="ChangeLog" | |
46 | |
47 # do command line checking | |
48 prog=`basename $0` | |
49 while [ -n "$1" ] | |
50 do | |
51 case "$1" in | |
52 --strip-prefix) | |
53 STRIPPREFIX="$2" | |
54 shift 2 | |
55 ;; | |
56 --linelen) | |
57 LINELEN="$2"; | |
58 shift 2 | |
59 ;; | |
60 --separate) | |
61 GROUPBYDAY="no"; | |
62 shift | |
63 ;; | |
64 -r|--include-rev) | |
65 INCLUDEREV="yes"; | |
66 shift | |
67 ;; | |
68 -O|--hg-options) | |
69 EXTRAOPTS="$2" | |
70 shift 2 | |
71 ;; | |
72 -o|--output) | |
73 CHANGELOG="$2" | |
74 shift 2 | |
75 ;; | |
76 --stdout) | |
77 CHANGELOG="-" | |
78 shift | |
79 ;; | |
80 -V|--version) | |
81 echo "$prog $VERSION"; | |
82 echo "Written by Arthur de Jong." | |
83 echo "Modified for Mercurial by Matti Hamalainen." | |
84 echo "Copyright (C) 2005 Arthur de Jong." | |
85 echo "Copyright (C) 2008 Matti Hamalainen." | |
86 echo "" | |
87 echo "This is free software; see the source for copying conditions. There is NO" | |
88 echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." | |
89 exit 0 | |
90 ;; | |
91 -h|--help) | |
92 echo "Usage: $prog [OPTION]..." | |
93 echo "Generate a ChangeLog from a checked out subversion repository." | |
94 echo "" | |
95 echo " --strip-prefix NAME prefix to strip from all entries, defaults" | |
96 echo " to the name of the current directory" | |
97 echo " --linelen NUM maximum length of an output line" | |
98 echo " --separate don't group changelog entries by day" | |
99 echo " -r, --include-rev include revision numbers" | |
100 echo " -o, --output FILE output to FILE instead of ChangeLog" | |
101 echo " --stdout output to stdout instead of ChangeLog" | |
102 echo " -O, --hg-options OPTS options passed to Mercurial" | |
103 echo " -h, --help display this help and exit" | |
104 echo " -V, --version output version information and exit" | |
105 exit 0 | |
106 ;; | |
107 *) | |
108 echo "$prog: invalid option -- $1" | |
109 echo "Try \`$prog --help' for more information." | |
110 exit 1 | |
111 ;; | |
112 esac | |
113 done | |
114 | |
115 # find the directory that this script resides in | |
116 prog="$0" | |
117 while test -h "$prog"; do | |
118 prog=`ls -ld "$prog" | sed "s/^.*-> \(.*\)/\1/;/^[^/]/s,^,$(dirname "$prog")/,"` | |
119 done | |
120 dir=`dirname $prog` | |
121 dir=`cd $dir && pwd` | |
122 XSL="$dir/svn2cl.xsl" | |
123 | |
124 # redirect stdout to the changelog file if needed | |
125 if test "x$CHANGELOG" != "x-"; then | |
126 exec > "$CHANGELOG" | |
127 fi | |
128 | |
129 # actually run the command we need | |
130 ( echo '<?xml version="1.0"?>' && | |
131 echo '<log>' && \ | |
132 hg log $EXTRAOPTS -M -v -f --template \ | |
133 '<logentry revision="#rev#"><author>#author|escape#</author><date>#date|isodate#</date><paths><path>#files#</path></paths><msg>#desc|escape#</msg></logentry>\n' && \ | |
134 echo '</log>' ) | \ | |
135 iconv -f "iso-8859-1" -t "utf-8" | \ | |
136 xsltproc --stringparam strip-prefix "$STRIPPREFIX" \ | |
137 --stringparam linelen $LINELEN \ | |
138 --stringparam groupbyday $GROUPBYDAY \ | |
139 --stringparam include-rev $INCLUDEREV \ | |
140 "$XSL" - |