Mercurial in complex workflows - Alexander Solovyov (PyGrunn conference)

Tags: python, pygrunn

Alexander is a mercurial (hg) contributor for 3 years.

With a traditional workflow, everyone has access to a central repository (like a subversion one). But you get too many conflicts that way. And unfinished work is hard to manage as you cannot reasonably check it in as it breaks everybody else’s checkout. And it is hard to do a quick fix to the existing code when you’re already working on some other feature.

Where to look for a better model? Open source. You’ve got a core team (gatekeepers), contributors and others. Developers submit changes, gatekeepers review them and changes are merged into the main line.

The point of this workflow:

  • You get exchange of experience. You get more interaction with novice developers and can instill experience, code style and professionalism as a core team member.

  • It prevents sad code.

  • You have collective code ownership. Anyone is allowed to commit everywhere (even though the gatekeepers of the various parts need to review).

Distributed version control systems (like mercurial) allow this. There’s zero effort for branching and merging. That just works. The changesets are stored in a much better way internally. And you’ve got total control of the situation: you can cherry-pick changesets instead of having to review basically big patches like in subversion.

Mercurial started in April 2005. Git and mercurial have the same age (there’s 3 days between them!). It is very fast (only git is a bit faster). 94% is python code, 6% is C. 30k lines of code. Git has a comparatively whopping 200k+ lines of code. Mercurial has a nice and clean python API for extensions.

Features are branches in a single repository. Every developer has its own repository on the server for his own branches. (He had more info here, but that was too quick to write down.)

A very nice feature of mercurial: type hg serve and you get a web interface for your local mercurial directory with all the available info on port 8000!

You can extend mercurial via the API:

  • You can tie into hooks.

  • You can wrap existing functions with custom functions. You can fill in commonly used arguments, for instance, so you don’t have to type them in by hand.

  • You can add your own commands.

dancing in the rain and in the water... logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):