More flags for releasenotes extension
GSoC’17 has almost come to an end and the third evaluation is a few days away. In the past two weeks, there have been some new additions to the features of release notes extension. The extension now supports similarity comparison for deduplication of content. This completes the basic features that are required in this extension. Contributors have already started adding the note sections inside commit messages (thanks to the reviewers). These will be later on used to create the release notes.
As discussed on the mailing list we needed some test to make sure that the commit message using restructured text are property created. Now since not all commit messages will contain release note areas so we decided to have a –check flag that can be used along with releaseqotes command.
The check command checks if there exists a admonition in the commit message, then whether it is a valid one or not. In this we basically make sure that the admonition being used, exists in default or custom admonitions. If false, it returns the error along with the changeset ID used. It also suggests an existing admonition name incase the invalid one is similar upto a certain threshold (say 0.7). This is simply done by using difflib SequenceMatcher.
sim = lambda x: difflib.SequenceMatcher(None,
admonition.group(1), x).ratio()
similar = [s for s in directives if sim(s) > 0.6]
if len(similar) == 1:
ui.write(_("(did you mean %s?)\n") % similar[0])
elif similar:
ss = ", ".join(sorted(similar))
ui.write(_("(did you mean one of %s?)\n") % ss)
Another feature that Pulkit suggested me was to add a command to view the list of admonitions that a user can use. This is a nice feature in terms of users with no prior experience of releasenotes extension (basically everyone). I implemented this using a simple function containing the following code:
for section in sections._sections:
ui.write(_(str(section[0]) + ": " + section[1] + "\n"))
This returns a list of all the admonitions mapped with their title. Something like
feature: New Features
bc: Backwards Compatibility Changes
fix: Bug Fixes
perf: Performance Improvements
api: API Changes
The command can be accessed using hg releasenotes -a
. That’s all for now from my side!