[PATCH 1 of 3 v4] releasenotes: add custom admonitions support for release notes
Yuya Nishihara
yuya at tcha.org
Tue Jul 18 09:55:36 EDT 2017
On Tue, 18 Jul 2017 18:10:18 +0530, Rishabh Madan wrote:
> # HG changeset patch
> # User Rishabh Madan <rishabhmadan96 at gmail.com>
> # Date 1500371554 -19800
> # Tue Jul 18 15:22:34 2017 +0530
> # Node ID d8997d12840aa113cde7ffa0ea7af8d62cf1add7
> # Parent 4672db164c986da4442bd864cd044512d975c3f2
> releasenotes: add custom admonitions support for release notes
> class releasenotessections(object):
> - def __init__(self, ui):
> - # TODO support defining custom sections from config.
> - self._sections = list(DEFAULT_SECTIONS)
> + def __init__(self, ui, repo=None):
> + if repo:
> + sections = dict(DEFAULT_SECTIONS)
> + custom_sections = getcustomadmonitions(repo)
> + if custom_sections:
> + sections.update(custom_sections)
> + self._sections = list(sections.iteritems())
The test fails at PATCH 3. It appears the order of sections is important
so you'll have to use util.sortdict() instead.
> +def getcustomadmonitions(repo):
> + custom_sections = list()
> + ctx = repo['.']
> + p = config.config()
> + repo = ctx.repo()
Meaningless re-assignment of repo.
> + def read(f, sections=None, remap=None):
> + if f in ctx:
> + data = ctx[f].data()
> + p.parse(f, data, sections, remap, read)
> + return p
No need to return p.
> + else:
> + raise error.Abort(_(".hgreleasenotes file \'%s\' not found") %
> + repo.pathto(f))
> +
> + if '.hgreleasenotes' in ctx:
> + configdict = read('.hgreleasenotes')
> + sectiondict = configdict['sections']
> + for key, value in sectiondict.iteritems():
> + temp = (key, value)
> + custom_sections.append(temp)
> + return custom_sections
This can be return p['sections'].
More information about the Mercurial-devel
mailing list