Show More
@@ -20,10 +20,12 b' import textwrap' | |||||
20 |
|
20 | |||
21 | from mercurial.i18n import _ |
|
21 | from mercurial.i18n import _ | |
22 | from mercurial import ( |
|
22 | from mercurial import ( | |
|
23 | config, | |||
23 | error, |
|
24 | error, | |
24 | minirst, |
|
25 | minirst, | |
25 | registrar, |
|
26 | registrar, | |
26 | scmutil, |
|
27 | scmutil, | |
|
28 | util, | |||
27 | ) |
|
29 | ) | |
28 |
|
30 | |||
29 | cmdtable = {} |
|
31 | cmdtable = {} | |
@@ -111,9 +113,15 b' class parsedreleasenotes(object):' | |||||
111 | self.addnontitleditem(section, paragraphs) |
|
113 | self.addnontitleditem(section, paragraphs) | |
112 |
|
114 | |||
113 | class releasenotessections(object): |
|
115 | class releasenotessections(object): | |
114 | def __init__(self, ui): |
|
116 | def __init__(self, ui, repo=None): | |
115 | # TODO support defining custom sections from config. |
|
117 | if repo: | |
116 |
|
|
118 | sections = util.sortdict(DEFAULT_SECTIONS) | |
|
119 | custom_sections = getcustomadmonitions(repo) | |||
|
120 | if custom_sections: | |||
|
121 | sections.update(custom_sections) | |||
|
122 | self._sections = list(sections.iteritems()) | |||
|
123 | else: | |||
|
124 | self._sections = list(DEFAULT_SECTIONS) | |||
117 |
|
125 | |||
118 | def __iter__(self): |
|
126 | def __iter__(self): | |
119 | return iter(self._sections) |
|
127 | return iter(self._sections) | |
@@ -128,6 +136,22 b' class releasenotessections(object):' | |||||
128 |
|
136 | |||
129 | return None |
|
137 | return None | |
130 |
|
138 | |||
|
139 | def getcustomadmonitions(repo): | |||
|
140 | ctx = repo['.'] | |||
|
141 | p = config.config() | |||
|
142 | ||||
|
143 | def read(f, sections=None, remap=None): | |||
|
144 | if f in ctx: | |||
|
145 | data = ctx[f].data() | |||
|
146 | p.parse(f, data, sections, remap, read) | |||
|
147 | else: | |||
|
148 | raise error.Abort(_(".hgreleasenotes file \'%s\' not found") % | |||
|
149 | repo.pathto(f)) | |||
|
150 | ||||
|
151 | if '.hgreleasenotes' in ctx: | |||
|
152 | read('.hgreleasenotes') | |||
|
153 | return p['sections'] | |||
|
154 | ||||
131 | def parsenotesfromrevisions(repo, directives, revs): |
|
155 | def parsenotesfromrevisions(repo, directives, revs): | |
132 | notes = parsedreleasenotes() |
|
156 | notes = parsedreleasenotes() | |
133 |
|
157 | |||
@@ -396,7 +420,7 b' def releasenotes(ui, repo, file_, rev=No' | |||||
396 | that file. A particular use case for this is to tweak the wording of a |
|
420 | that file. A particular use case for this is to tweak the wording of a | |
397 | release note after it has been added to the release notes file. |
|
421 | release note after it has been added to the release notes file. | |
398 | """ |
|
422 | """ | |
399 | sections = releasenotessections(ui) |
|
423 | sections = releasenotessections(ui, repo) | |
400 |
|
424 | |||
401 | revs = scmutil.revrange(repo, [rev or 'not public()']) |
|
425 | revs = scmutil.revrange(repo, [rev or 'not public()']) | |
402 | incoming = parsenotesfromrevisions(repo, sections.names(), revs) |
|
426 | incoming = parsenotesfromrevisions(repo, sections.names(), revs) | |
@@ -416,7 +440,7 b' def releasenotes(ui, repo, file_, rev=No' | |||||
416 | fh.write(serializenotes(sections, notes)) |
|
440 | fh.write(serializenotes(sections, notes)) | |
417 |
|
441 | |||
418 | @command('debugparsereleasenotes', norepo=True) |
|
442 | @command('debugparsereleasenotes', norepo=True) | |
419 | def debugparsereleasenotes(ui, path): |
|
443 | def debugparsereleasenotes(ui, path, repo=None): | |
420 | """parse release notes and print resulting data structure""" |
|
444 | """parse release notes and print resulting data structure""" | |
421 | if path == '-': |
|
445 | if path == '-': | |
422 | text = sys.stdin.read() |
|
446 | text = sys.stdin.read() | |
@@ -424,7 +448,7 b' def debugparsereleasenotes(ui, path):' | |||||
424 | with open(path, 'rb') as fh: |
|
448 | with open(path, 'rb') as fh: | |
425 | text = fh.read() |
|
449 | text = fh.read() | |
426 |
|
450 | |||
427 | sections = releasenotessections(ui) |
|
451 | sections = releasenotessections(ui, repo) | |
428 |
|
452 | |||
429 | notes = parsereleasenotesfile(sections, text) |
|
453 | notes = parsereleasenotesfile(sections, text) | |
430 |
|
454 |
@@ -255,6 +255,8 b' Now add bullet points to sections having' | |||||
255 |
|
255 | |||
256 | * Short summary of fix 3 |
|
256 | * Short summary of fix 3 | |
257 |
|
257 | |||
|
258 | $ cd .. | |||
|
259 | ||||
258 | Multiple 'Other Changes' sub-sections for every section |
|
260 | Multiple 'Other Changes' sub-sections for every section | |
259 |
|
261 | |||
260 | $ hg init multiple-otherchanges |
|
262 | $ hg init multiple-otherchanges | |
@@ -324,3 +326,53 b" Multiple 'Other Changes' sub-sections fo" | |||||
324 |
|
326 | |||
325 | * Short summary of fix 2 |
|
327 | * Short summary of fix 2 | |
326 |
|
328 | |||
|
329 | $ cd .. | |||
|
330 | ||||
|
331 | Using custom sections in notes | |||
|
332 | ||||
|
333 | $ hg init custom-section | |||
|
334 | $ cd custom-section | |||
|
335 | $ cat >> .hgreleasenotes << EOF | |||
|
336 | > [sections] | |||
|
337 | > testsection=Name of Section | |||
|
338 | > EOF | |||
|
339 | ||||
|
340 | $ touch a | |||
|
341 | $ hg -q commit -A -l - << EOF | |||
|
342 | > commit 1 | |||
|
343 | > | |||
|
344 | > .. testsection:: | |||
|
345 | > | |||
|
346 | > First paragraph under this admonition. | |||
|
347 | > EOF | |||
|
348 | ||||
|
349 | $ hg releasenotes -r . $TESTTMP/relnotes-custom-section | |||
|
350 | $ cat $TESTTMP/relnotes-custom-section | |||
|
351 | Name of Section | |||
|
352 | =============== | |||
|
353 | ||||
|
354 | * First paragraph under this admonition. | |||
|
355 | ||||
|
356 | Overriding default sections (For eg. by default feature = New Features) | |||
|
357 | ||||
|
358 | $ cat >> .hgreleasenotes << EOF | |||
|
359 | > [sections] | |||
|
360 | > feature=Feature Additions | |||
|
361 | > EOF | |||
|
362 | ||||
|
363 | $ touch b | |||
|
364 | $ hg -q commit -A -l - << EOF | |||
|
365 | > commit 2 | |||
|
366 | > | |||
|
367 | > .. feature:: | |||
|
368 | > | |||
|
369 | > Adds a new feature. | |||
|
370 | > EOF | |||
|
371 | ||||
|
372 | $ hg releasenotes -r . $TESTTMP/relnotes-override-section | |||
|
373 | $ cat $TESTTMP/relnotes-override-section | |||
|
374 | Feature Additions | |||
|
375 | ================= | |||
|
376 | ||||
|
377 | * Adds a new feature. | |||
|
378 |
General Comments 0
You need to be logged in to leave comments.
Login now