comparison tests/test-releasenotes-formatting.t @ 32778:91e355a0408b

releasenotes: command to manage release notes files Per discussion on the mailing list, we want better release notes for Mercurial. This patch introduces an extension that provides a command for producing release notes files. Functionality is implemented as an extension because it could be useful outside of the Mercurial project and because there is some code (like rst parsing) that already exists in Mercurial and it doesn't make sense to reinvent the wheel. The general idea with the extension is that changeset authors declare release notes in commit messages using rst directives. Periodically (such as at publishing or release time), a project maintainer runs `hg releasenotes` to extract release notes fragments from commit messages and format them to an auto-generated release notes file. More details are explained inline in docstrings. There are several things that need addressed before this is ready for prime time: * Moar tests * Interactive merge mode * Implement similarity detection for individual notes items * Support customizing section names/titles * Parsing improvements for bullet lists and paragraphs * Document which rst primitives can be parsed * Retain arbitrary content (e.g. header section/paragraphs) from existing release notes file * Better error messages (line numbers, hints, etc)
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 02 Jun 2017 23:33:30 +0200
parents
children 2510823ca0df
comparison
equal deleted inserted replaced
32777:9dccaff02ad5 32778:91e355a0408b
1 $ cat >> $HGRCPATH << EOF
2 > [extensions]
3 > releasenotes=
4 > EOF
5
6 $ hg init simple-repo
7 $ cd simple-repo
8
9 A fix with a single line results in a bullet point in the appropriate section
10
11 $ touch fix1
12 $ hg -q commit -A -l - << EOF
13 > single line fix
14 >
15 > .. fix::
16 >
17 > Simple fix with a single line content entry.
18 > EOF
19
20 $ hg releasenotes -r . $TESTTMP/relnotes-single-line
21
22 $ cat $TESTTMP/relnotes-single-line
23 Bug Fixes
24 =========
25
26 * Simple fix with a single line content entry.
27
28 A fix with multiple lines is handled correctly
29
30 $ touch fix2
31 $ hg -q commit -A -l - << EOF
32 > multi line fix
33 >
34 > .. fix::
35 >
36 > First line of fix entry.
37 > A line after it without a space.
38 >
39 > A new paragraph in the fix entry. And this is a really long line. It goes on for a while.
40 > And it wraps around to a new paragraph.
41 > EOF
42
43 $ hg releasenotes -r . $TESTTMP/relnotes-multi-line
44 $ cat $TESTTMP/relnotes-multi-line
45 Bug Fixes
46 =========
47
48 * First line of fix entry. A line after it without a space.
49
50 A new paragraph in the fix entry. And this is a really long line. It goes on
51 for a while. And it wraps around to a new paragraph.
52
53 A release note with a title results in a sub-section being written
54
55 $ touch fix3
56 $ hg -q commit -A -l - << EOF
57 > fix with title
58 >
59 > .. fix:: Fix Title
60 >
61 > First line of fix with title.
62 >
63 > Another paragraph of fix with title. But this is a paragraph
64 > with multiple lines.
65 > EOF
66
67 $ hg releasenotes -r . $TESTTMP/relnotes-fix-with-title
68 $ cat $TESTTMP/relnotes-fix-with-title
69 Bug Fixes
70 =========
71
72 Fix Title
73 ---------
74
75 First line of fix with title.
76
77 Another paragraph of fix with title. But this is a paragraph with multiple
78 lines.
79
80 $ cd ..
81
82 Formatting of multiple bullet points works
83
84 $ hg init multiple-bullets
85 $ cd multiple-bullets
86 $ touch fix1
87 $ hg -q commit -A -l - << EOF
88 > commit 1
89 >
90 > .. fix::
91 >
92 > first fix
93 > EOF
94
95 $ touch fix2
96 $ hg -q commit -A -l - << EOF
97 > commit 2
98 >
99 > .. fix::
100 >
101 > second fix
102 >
103 > Second paragraph of second fix.
104 > EOF
105
106 $ touch fix3
107 $ hg -q commit -A -l - << EOF
108 > commit 3
109 >
110 > .. fix::
111 >
112 > third fix
113 > EOF
114
115 $ hg releasenotes -r 'all()' $TESTTMP/relnotes-multiple-bullets
116 $ cat $TESTTMP/relnotes-multiple-bullets
117 Bug Fixes
118 =========
119
120 * first fix
121
122 * second fix
123
124 Second paragraph of second fix.
125
126 * third fix
127
128 $ cd ..
129
130 Formatting of multiple sections works
131
132 $ hg init multiple-sections
133 $ cd multiple-sections
134 $ touch fix1
135 $ hg -q commit -A -l - << EOF
136 > commit 1
137 >
138 > .. fix::
139 >
140 > first fix
141 > EOF
142
143 $ touch feature1
144 $ hg -q commit -A -l - << EOF
145 > commit 2
146 >
147 > .. feature::
148 >
149 > description of the new feature
150 > EOF
151
152 $ touch fix2
153 $ hg -q commit -A -l - << EOF
154 > commit 3
155 >
156 > .. fix::
157 >
158 > second fix
159 > EOF
160
161 $ hg releasenotes -r 'all()' $TESTTMP/relnotes-multiple-sections
162 $ cat $TESTTMP/relnotes-multiple-sections
163 New Features
164 ============
165
166 * description of the new feature
167
168 Bug Fixes
169 =========
170
171 * first fix
172
173 * second fix
174
175 $ cd ..
176
177 Section with subsections and bullets
178
179 $ hg init multiple-subsections
180 $ cd multiple-subsections
181
182 $ touch fix1
183 $ hg -q commit -A -l - << EOF
184 > commit 1
185 >
186 > .. fix:: Title of First Fix
187 >
188 > First paragraph of first fix.
189 >
190 > Second paragraph of first fix.
191 > EOF
192
193 $ touch fix2
194 $ hg -q commit -A -l - << EOF
195 > commit 2
196 >
197 > .. fix:: Title of Second Fix
198 >
199 > First paragraph of second fix.
200 >
201 > Second paragraph of second fix.
202 > EOF
203
204 $ hg releasenotes -r 'all()' $TESTTMP/relnotes-multiple-subsections
205 $ cat $TESTTMP/relnotes-multiple-subsections
206 Bug Fixes
207 =========
208
209 Title of First Fix
210 ------------------
211
212 First paragraph of first fix.
213
214 Second paragraph of first fix.
215
216 Title of Second Fix
217 -------------------
218
219 First paragraph of second fix.
220
221 Second paragraph of second fix.
222
223 Now add bullet points to sections having sub-sections
224
225 $ touch fix3
226 $ hg -q commit -A -l - << EOF
227 > commit 3
228 >
229 > .. fix::
230 >
231 > Short summary of fix 3
232 > EOF
233
234 $ hg releasenotes -r 'all()' $TESTTMP/relnotes-multiple-subsections-with-bullets
235 $ cat $TESTTMP/relnotes-multiple-subsections-with-bullets
236 Bug Fixes
237 =========
238
239 Title of First Fix
240 ------------------
241
242 First paragraph of first fix.
243
244 Second paragraph of first fix.
245
246 Title of Second Fix
247 -------------------
248
249 First paragraph of second fix.
250
251 Second paragraph of second fix.
252
253 Other Changes
254 -------------
255
256 * Short summary of fix 3