D454: releasenotes: view admonition titles using -a flag
rishabhmadan96 (Rishabh Madan)
phabricator at mercurial-scm.org
Sun Aug 20 16:33:47 UTC 2017
rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
Since this extension is fairly new for almost all the contributors, remembering
the admonition (with titles) is difficult. The admonition (-a) flag provides
a list of all the active admonitions along with titles.
For usage, `hg releasenotes -a` returns the list.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D454
AFFECTED FILES
hgext/releasenotes.py
tests/test-releasenotes-formatting.t
CHANGE DETAILS
diff --git a/tests/test-releasenotes-formatting.t b/tests/test-releasenotes-formatting.t
--- a/tests/test-releasenotes-formatting.t
+++ b/tests/test-releasenotes-formatting.t
@@ -407,3 +407,12 @@
$ hg releasenotes -r . -c
Invalid admonition 'fixes' present in changeset 0e7130d2705c
(did you mean fix?)
+
+Usage of --admonition flag
+
+ $ hg releasenotes -a
+ feature: New Features
+ bc: Backwards Compatibility Changes
+ fix: Bug Fixes
+ perf: Performance Improvements
+ api: API Changes
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -275,6 +275,10 @@
ss = ", ".join(sorted(similar))
ui.write(_("(did you mean one of %s?)\n") % ss)
+def getadmonitionlist(ui, sections):
+ for section in sections._sections:
+ ui.write(_(str(section[0]) + ": " + section[1] + "\n"))
+
def parsenotesfromrevisions(repo, directives, revs):
notes = parsedreleasenotes()
@@ -467,7 +471,8 @@
@command('releasenotes',
[('r', 'rev', '', _('revisions to process for release notes'), _('REV')),
('c', 'check', False, _('checks for validity of admonitions (if any)'),
- _('REV'))],
+ _('REV')),
+ ('a', 'admonition', False, _('returns admonition and its title'), None)],
_('hg releasenotes [-r REV] [-c] FILE'))
def releasenotes(ui, repo, file_=None, **opts):
"""parse release notes from commit messages into an output file
@@ -546,6 +551,9 @@
release note after it has been added to the release notes file.
"""
sections = releasenotessections(ui, repo)
+ if opts.get('admonition'):
+ return getadmonitionlist(ui, sections)
+
rev = opts.get('rev')
revs = scmutil.revrange(repo, [rev or 'not public()'])
To: rishabhmadan96, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list