mu4e Email Dev Flow

While Pull Requests on GitHub or BitBucket are probably what most developers are used to these days, those came about after git and mercurial. Before GitHub, the norm was sending patches over email, which git and mercurial still support quite well and many projects prefer as the means of sharing patches. sourcehut is a new platform for hosting code which, among other things, is leveraging the email workflow for patches. The suggested workflow at sourcehut is to create a mailing list (which sourcehut can host) and users can then email patches to the list. A review takes place over email and eventually the patch is applied. There are some clear strengths to this:

  1. Users can use whatever client they want to look at, review, and send patches. While hating on email is popular these days, it is an open protocol with many clients. There is, effectively, only one GitHub Pull Request client, so we are stuck with whatever choices GitHub makes.
  2. Users who wish to contribute do not need a sourcehut account. They can clone the repository, make changes locally, and then email them to the list for review. There is no concept of "forking" as exists in GitHub and BitBucket. Makes code development federated, and distributed, kind of what one would expect from a DVCS.

Drew, the creator of sourcehut (among many other things), has written a blog post about this:

https://drewdevault.com/2019/05/24/What-is-a-fork.html

But assuming you have bought into this, one question is: how to apply patches? The mailing list functionality of sourcehut provides a link that one can import a change in from easily, for example:

hg import https://lists.sr.ht/path/to/the/patch

sourcehut has some documentation on this for git and mercurial.

In the case of some of your author's repositories on sourcehut, they are on private mailing lists so that solution doesn't work because one has to be logged into sourcehut to the messages.

But, your author is a user of mu4e for email, and handling this is actually pretty easy. Once the patch you wish to apply is opened in mu4e, all you need to do is:

M-x cd RET
/path/to/location/of/repo RET
| hg import -

In words:

  1. Change current working directory for the buffer to the location of the repo using the cd function in emacs.
  2. Hit |, mu4e will pipe the email through a command.
  3. The command in this case is `hg import -` which reads a patch from stdin and applies it to the repository in the current working directory.

Now you can apply patches easily from public or private lists on sourcehut.

Enjoy.