Alpine Mail Client

Lately, I’ve been using Alpine for emails on my servers. It’s a great command line, curses based, mail client. This post is a quick howto for using Alpine for patching Python (or any) code on a production server.

Let’s get started…

# apt install alpine

I like to alias alpine to pine in my .bashrc

The default screen when you launch Alpine is this:

Alpine Main Menu

Like many people, I prefer to see my inbox when I open my mail client. This is easily achieved by typing S C from the main menu. Then, page down until you see “Initial Keystroke List”

Alpine Configuration

Type C to change the value to i for inbox then e to exit setup and y to confirm this change. From now on, when you type pine or alpine you’ll be straight in your inbox. If you want to go the menu, it’s simply an m keystroke away.

Here is my inbox:

Alpine Inbox

As you can see, I’ve mailed myself 4 patches from my home computer which I’ll be applying on the production server.

Highlight message 6, and then type the pipe character |. Alpine now wants a command which you can see near the bottom.

Alpine Pipe Command

Press Enter and see what happens.

Alpine Patching

As you can see, Patch has not been able to apply the patch as I have a deliberate error. I was not in the correct directory where the code is. So what I do is make sure I’m in the correct directory before I launch Alpine. Once you’ve done that, all should be good. I’d advise you to use the --dry-run option to patch to check for errors, before actually applying the patch or patch series!

Mercurial Patchbomb

For the above to work, you need to enable the Patchbomb extension. It’s included with Mercurial so you just need to enable it. In your ~/.hgrc add the extension as below:

# uncomment these lines to enable some popular extensions
# (see 'hg help extensions' for more info)
patchbomb = 

And finally, in your Mercurial repository .hg/hgrc add the following. This will send your patches silently to your server. If you don’t do this, you’ll have to specify a recipient and whether you want to CC anyone.

simon@computer:~/code/project$ cat .hg/hgrc
to =
cc = 

So now, you can simply run

simon@computer:~/code/project$ hg email -r tip

Patchbomb will inform you what it’s sending:

simon@computer:~/code/project$ hg email -r tip
this patch series consists of 1 patches.

sending [PATCH] revert tacit css to unmodified version ...

If you want or need to send multiple patches, you can do that like so:

simon@computer:~/code/project$ hg email -r 130:-r tip

You’ll be given the opportunity to provide some details for the patch series which appear in [Patch 0 of 7]

Multiple Patches

And it’s as simple as that!