Patchwork D454: releasenotes: view admonition titles using -l flag

login
register
mail settings
Submitter phabricator
Date Aug. 27, 2017, 10:44 p.m.
Message ID <edb9657a32f4f529004ae02bba0c66d9@localhost.localdomain>
Download mbox | patch
Permalink /patch/23378/
State Not Applicable
Headers show

Comments

phabricator - Aug. 27, 2017, 10:44 p.m.
rishabhmadan96 updated this revision to Diff 1331.
rishabhmadan96 edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D454?vs=1123&id=1331

REVISION DETAIL
  https://phab.mercurial-scm.org/D454

AFFECTED FILES
  hgext/releasenotes.py
  tests/test-releasenotes-formatting.t

CHANGE DETAILS




To: rishabhmadan96, #hg-reviewers, pulkit, yuja
Cc: yuja, pulkit, mercurial-devel

Patch

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,16 @@ 
   $ hg releasenotes -r . -c
   Invalid admonition 'fixes' present in changeset 0e7130d2705c
   (did you mean fix?)
+
+  $ cd ..
+
+Usage of --list flag
+
+  $ hg init relnotes-list
+  $ cd relnotes-list
+  $ hg releasenotes -l
+  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:
+        ui.write("%s: %s\n" % (section[0], section[1]))
+
 def parsenotesfromrevisions(repo, directives, revs):
     notes = parsedreleasenotes()
 
@@ -467,7 +471,9 @@ 
 @command('releasenotes',
     [('r', 'rev', '', _('revisions to process for release notes'), _('REV')),
     ('c', 'check', False, _('checks for validity of admonitions (if any)'),
-        _('REV'))],
+        _('REV')),
+    ('l', 'list', False, _('list the available admonitions with their 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,8 +552,10 @@ 
     release note after it has been added to the release notes file.
     """
     sections = releasenotessections(ui, repo)
+    if opts.get('list'):
+        return _getadmonitionlist(ui, sections)
+
     rev = opts.get('rev')
-
     revs = scmutil.revrange(repo, [rev or 'not public()'])
     if opts.get('check'):
         return checkadmonitions(ui, repo, sections.names(), revs)