And now for something completely Pythonic...

Extending Mercurial

written by Georg, on Monday, November 24, 2008 20:24.

After releasing Sphinx 0.5 and Pygments 1.0 yesterday, I had to relax somewhat, so I wrote something I've always missed: both for Python and my projects, many commits get an entry in the project's changelog file, so I end up writing the log message twice: once into the changelog, once as the commit message.

Since I've been playing around with Mercurial and its extensions, I did it as a new extension that wraps around the commit command: it looks if a new changelog entry is in the committed changes, and in that case lets the commit message default to this entry.

It has been really easy to implement this. Mercurial code is very clean and concise, and the API doesn't require you to call five methods on seven different instances just to get at a diff of changes.

The code is, of course, in a repo. It doesn't work with hg 1.0 because I'm too lazy to rewrite the nice command wrapping helper they added in the trunk :)

Comments

  1. This might seem silly, but I noticed in the 0.5 CHANGELOG that i18n support was added. I've been unable to find anywhere that actually explains how one would actually use it though.... am I missing those docs?

    —  gaspode on Tuesday, November 25, 2008 7:45 #

  2. George do you have a timeline in mind for Python 3 support for Pygments?

    —  Michael Watkins on Tuesday, November 25, 2008 17:05 #

  3. @gaspode: see this section in the docs. Basically, if your language is supported you only set this value and are all set.

    @Michael: there should already be a Python3Lexer :)

    —  Georg on Tuesday, November 25, 2008 18:42 #

  4. Georg - thanks, I was aware of the Python3Lexer; mostly I was wondering about when some of these great tools will be available on Python 3.

    The package I miss most over on Python 3 is docutils, and I'd also add Pygments to that.

    I did note your Nov 25th post on the docutils mailing list. :-)

    I recently had a quick look at 2to3'ing docutils and decided very quickly that what was left to do was beyond my understanding of the insides of docutils.

    —  Michael Watkins on Thursday, November 27, 2008 16:06 #

  5. Ah, now I understand. Yes, if I want Sphinx to work on 3k, Pygments will also have to ported.

    I've already made an attempt to convert it, and since it's smaller than docutils, and most of the lexer definitions won't need any work at all, I expect a Python 3 egg will be available with the next release.

    —  Georg on Thursday, November 27, 2008 17:05 #

Commenting is no longer possible.