Mercurial Queues

Chris Mason has been working on a very useful extension to Mercurial called Mercurial Queues, or mq for short.

It has languished in semi-obscurity for a while on SuSE’s ftp servers, so we’ve made a repository available for people to pull from directly.

Several years ago, Andrew Morton published some scripts that he used to manage patches to the Linux kernel. These got turned into a set of tools called quilt. The quilt tools are popular among developers who need to maintain a set of changes to a changing source tree over a long period of time, without integrating those changes into the main source tree.

The idea (expressed more completely in this paper) is that you make a pile of related changes in a working directory, then use quilt to turn those changes into a patch. Make some more changes, then use quilt to turn those, in turn, into another patch that applies on top of the original patch. These patches accumulate in a stack; you can push and pop patches as you need to. Quilt also helps with integration of “upstream” changes; it has a refresh command that re-applies all patches to a tree, and stops at the first one that contains conflicts, so you can regenerate the patch.

This patch management and refresh capability is useful in two important scenarios.

  • For outside contributors to projects that use centralised tools like CVS and Subversion, where one doesn’t have commit access to the central repository, quilt makes it much easier to develop and track local changes.
  • With a work in progress that has a long lifetime, quilt makes it easier to “re-base” work off a more recent upstream revision without committing potentially destabilising changes. Even with a distributed SCM, this can be useful, as it prevents the change history from becoming littered with merges and false starts that convey little useful information.
  • Quilt works entirely outside of a revison control system, which is a strength and a weakness. The advantage this confers is SCM neutrality; quilt works in the same way whether you are working with source tarballs, CVS clients, Subversion, or anything else. On the down side, because quilt is external to the SCM, you have to learn two ways to do everything, and remember whether you need to be using a quilt command or an SCM command in a particular context.

    Chris’s Mercurial Queues extension brings quilt-like functionality into Mercurial. It adds to Mercurial the ability to push, pop, and refresh work, while letting you use normal Mercurial commands to examine the state of your working directory, view history, propagate changes, and so on.

    This is officially Way Cool. Having quilt’s power without requiring that we tip-toe around behind the back of the SCM is excellent.

    Mercurial Queues is in the final stages of polishing up at the moment; with a bit of work, it will be integrated into the main Mercurial tree in the nearish future.

Posted in scm, software

Leave a Reply

Your email address will not be published. Required fields are marked *