Google Summer of Code 2019 Report: Mercurial

I’ll try to explain the things I’ve done during my summers with Mercurial as a part of GSoC ‘19.

What is Mercurial?

Mercurial is a free, distributed source control management tool. It efficiently handles projects of any size and offers an easy and intuitive interface. Most of the code is written in Python but, it also relies on C and Rust for the sake of performance.

About my project

Merge conflicts are every developer’s nightmare. While working with a community on a large codebase, you are likely to get enormous conflicts. A developer might start immediately resolving conflicts and after partially resolved, they might have to fix an urgent bug. Until now, there are two options, viz. discard the resolved conflicts or complete the conflict resolution before they fix the bug. My project is about adding a storage mechanism in the changeset level for this partially resolved mergestate to restore for later.

The following mentors were assigned to me:

I have written my progress during the GSoC period every week here.

Making shelve to handle mergestate

My proposed method in the GSoC proposal is about adding two commands, viz. hg store-conflicts and hg restore-conflicts. However, after the community bonding period, most of the members voted for an approach which is adding an --unresolved flag to the existing hg shelve and hg unshelve commands.

The following patches were made:

Since not enough people were available to review the patches, these are still in progress. But, thanks to my mentor Pulkit. He insisted on doing other things which are very much requested by the community and could make a good impact on Mercurial.

The following tasks were assigned to me:

  • Moving shelve extension to the core
  • Adding interactive mode to hg unshelve
  • Adding more use cases of config registrar (issue6014)
  • Handling bookmarks pointing to secret changesets (issue6159)

Moving shelve extension to the core

The shelve extension is a much-used extension and my mentor suggested me on moving the extension to the core by turning on by default. The discussion was initiated in this mail thread.

The following patches were merged:

Adding interactive mode to unshelve

An option to unshelve changes interactively wasn’t there. This makes Mercurial to only unshelve selected changes from the stored shelved change. This was a requested feature in the bug description I spent time working on this.

The output of the change was so beautiful and it motivated me to work on further things with hg shelve .

Demo of `unshelve — interactive` with curses ui

The following patches were merged and queued to stable for release:

Adding more use cases of config registrar

Mercurial has a config registrar. But, hg showconfig lacked some of its use cases. This is described in this bug report

I had to add two things:

  • -a/--all option to include all known configs
  • {defaultvalue} keyword to be used with -T/--template
  • An experimental argument to the config registrar items to distinguish the experimental config options which are not known by experimental section.

The following patches were sent:

Handling bookmarks pointing to secret changesets

On pushing bookmarks which point to secret changesets, the changesets are not pushed but, the bookmarks are still pushed. This confuses the server. It will have bookmarks pointing to non-existent changesets in the remote. We needed to abort in such situations. This issue was described in this bug report

The following patches were merged:

Future work

Some of the improvements can be made in the functionalities I have worked on are:

  • Landing patches on —unresolved in the core.
  • On a partial unshelve using interactive mode, make it less likely to get into merge conflicts.
  • Add functionality to exchange shelved changes.

I have patches that are still in progress. I shall wait for more reviews as the developers get free. I’m very much thankful to my mentor Pulkit to make my time efficient by giving tasks required at the moment and replying to my doubts fast even on his busy schedule. I hope to interact with the current Mercurial developers in the upcoming code sprint and talk about the work I’d done. I’m hoping to get involved in the community further by being active in the communication channels and sending patches to the core occasionally.