Custom Sections [CHECK]


The last time I discussed about adding support for custom sections to release notes extension. Over the past few days, with the help of the Yuya and Kevin, who reviewed my patches, I finally managed to implement a proper function and related things in the extension. In order to accomplish this task I made use of the config class from the Mercurial core API. It is a really sophisticated class that comprises of almost all the functions like get(), set(), parse() for tinkering with the config files. I decided to use the parse() function that basically reads through the provided config file and parses all the text in the form of a dictionary consisting of key, value pairs. In our case, every custom directive name was valued with its section name. It was a really easy thing to accomplish once I got comfortable with the use of config. Finally, the patch was merged into the default branch. Feel free to access it here.

One nice thing that I learned about dicts was the update() and iteritems() functions. While implementing the function for adding custom sections, we decided that just in case a default admonition with a different section name is specified in the config file, then it should override the default section name for that particular directive. I initially wrote a couple of lines of code for this thing but then Yuya suggested me to simply use the update function for this task. I was under the impression that update basically adds a key, value pair to the dictionary. But it also updates the value of the existing key, which solved the problem of override in a single line. I also made using of dict.iteritems() for storing the details about the dict. Apparently, it takes less memory and time in comparison to dict.items()

Sync flag for updating notes


One more thing that we want from this extension is a sync feature. Let’s say John is a developer using this extension who doesn’t remember when he last updated the notes and wants to update the notes from that point till the latest changeset.The sync flag is the magic word for John. He simply updates the notes using hg releasenotes --sync [FILENAME] and it works! To add this feature, an important thing that we want is to remember the last changeset till which the notes are synced. One way of doing this is to store the changeset ID of this commit in a file. To have this for different branches, we can store the last synced changeset ID for each branch individually. I have initially implemented a prototype function that is working for a single branch, and I am now working on having it for different branches or heads.

Now that my other project is over, I can easily devote more time working on this extension. So that’s all for now!