Mercurial > hg
comparison hgext/releasenotes.py @ 33940:2a37459aedf2
releasenotes: view admonition titles using -l flag
Since this extension is fairly new for almost all the contributors, remembering
the admonition (with titles) is difficult. The list (-l) flag provides
a list of all the active admonitions along with titles.
For usage, hg releasenotes -l returns the list.
Differential Revision: https://phab.mercurial-scm.org/D454
author | Rishabh Madan <rishabhmadan96@gmail.com> |
---|---|
date | Mon, 28 Aug 2017 04:11:58 +0530 |
parents | 6a49c74b1e8f |
children | 741a511492d3 |
comparison
equal
deleted
inserted
replaced
33939:9d5d040160e6 | 33940:2a37459aedf2 |
---|---|
272 if len(similar) == 1: | 272 if len(similar) == 1: |
273 ui.write(_("(did you mean %s?)\n") % similar[0]) | 273 ui.write(_("(did you mean %s?)\n") % similar[0]) |
274 elif similar: | 274 elif similar: |
275 ss = ", ".join(sorted(similar)) | 275 ss = ", ".join(sorted(similar)) |
276 ui.write(_("(did you mean one of %s?)\n") % ss) | 276 ui.write(_("(did you mean one of %s?)\n") % ss) |
277 | |
278 def _getadmonitionlist(ui, sections): | |
279 for section in sections: | |
280 ui.write("%s: %s\n" % (section[0], section[1])) | |
277 | 281 |
278 def parsenotesfromrevisions(repo, directives, revs): | 282 def parsenotesfromrevisions(repo, directives, revs): |
279 notes = parsedreleasenotes() | 283 notes = parsedreleasenotes() |
280 | 284 |
281 for rev in revs: | 285 for rev in revs: |
465 return '\n'.join(lines) | 469 return '\n'.join(lines) |
466 | 470 |
467 @command('releasenotes', | 471 @command('releasenotes', |
468 [('r', 'rev', '', _('revisions to process for release notes'), _('REV')), | 472 [('r', 'rev', '', _('revisions to process for release notes'), _('REV')), |
469 ('c', 'check', False, _('checks for validity of admonitions (if any)'), | 473 ('c', 'check', False, _('checks for validity of admonitions (if any)'), |
470 _('REV'))], | 474 _('REV')), |
475 ('l', 'list', False, _('list the available admonitions with their title'), | |
476 None)], | |
471 _('hg releasenotes [-r REV] [-c] FILE')) | 477 _('hg releasenotes [-r REV] [-c] FILE')) |
472 def releasenotes(ui, repo, file_=None, **opts): | 478 def releasenotes(ui, repo, file_=None, **opts): |
473 """parse release notes from commit messages into an output file | 479 """parse release notes from commit messages into an output file |
474 | 480 |
475 Given an output file and set of revisions, this command will parse commit | 481 Given an output file and set of revisions, this command will parse commit |
544 this command and changes should not be lost when running this command on | 550 this command and changes should not be lost when running this command on |
545 that file. A particular use case for this is to tweak the wording of a | 551 that file. A particular use case for this is to tweak the wording of a |
546 release note after it has been added to the release notes file. | 552 release note after it has been added to the release notes file. |
547 """ | 553 """ |
548 sections = releasenotessections(ui, repo) | 554 sections = releasenotessections(ui, repo) |
555 if opts.get('list'): | |
556 return _getadmonitionlist(ui, sections) | |
557 | |
549 rev = opts.get('rev') | 558 rev = opts.get('rev') |
550 | |
551 revs = scmutil.revrange(repo, [rev or 'not public()']) | 559 revs = scmutil.revrange(repo, [rev or 'not public()']) |
552 if opts.get('check'): | 560 if opts.get('check'): |
553 return checkadmonitions(ui, repo, sections.names(), revs) | 561 return checkadmonitions(ui, repo, sections.names(), revs) |
554 | 562 |
555 incoming = parsenotesfromrevisions(repo, sections.names(), revs) | 563 incoming = parsenotesfromrevisions(repo, sections.names(), revs) |