More on Patch Management

As you grow familiar with MQ, you will find yourself wanting to perform other kinds of patch management operations.

Deleting Unwanted Patches

If you want to get rid of a patch, use the hg qdelete command to delete the patch file and remove its entry from the patch series. If you try to delete a patch that is still applied, hg qdelete will refuse.

$ hg init myrepo
$ cd myrepo
$ hg qinit
$ hg qnew bad.patch
$ echo a > a
$ hg add a
$ hg qrefresh
$ hg qdelete bad.patch
abort: cannot delete applied patch bad.patch
$ hg qpop
patch queue now empty
$ hg qdelete bad.patch

Converting to and from Permanent Revisions

Once you’re done working on a patch and want to turn it into a permanent changeset, use the hg qfinish command. Pass a revision to the command to identify the patch that you want to turn into a regular changeset; this patch must already be applied.

$ hg qnew good.patch
$ echo a > a
$ hg add a
$ hg qrefresh -m 'Good change'
$ hg qfinish tip
$ hg qapplied
$ hg tip --style=compact
0[tip]   3c8b7fe3998b   2009-05-05 06:44 +0000   bos
  Good change

The hg qfinish command accepts an --all or -a option, which turns all applied patches into regular changesets.

It is also possible to turn an existing changeset into a patch, by passing the -r option to hg qimport.

$ hg qimport -r tip
$ hg qapplied
0.diff

Note that it only makes sense to convert a changeset into a patch if you have not propagated that changeset into any other repositories. The imported changeset’s ID will change every ...

Get Mercurial: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.