Identifying Patches

MQ commands that work with patches let you refer to a patch either by using its name or by a number. By name is obvious enough; pass the name foo.patch to qpush, for example, and it will push patches until foo.patch is applied.

As a shortcut, you can refer to a patch using both a name and a numeric offset; foo.patch-2 means two patches before foo.patch, while bar.patch+4 means four patches after bar.patch.

Referring to a patch by index isn’t much different. The first patch printed in the output of qseries is patch zero (yes, it’s one of those start-at-zero counting systems); the second is patch one; and so on.

MQ also makes it easy to work with patches when you are using normal Mercurial commands. Every command that accepts a changeset ID will also accept the name of an applied patch. MQ augments the tags normally in the repository with an eponymous one for each applied patch. In addition, the special tags qbase and qtip identify the bottom-most and topmost applied patches, respectively.

These additions to Mercurial’s normal tagging capabilities make dealing with patches even more of a breeze.

  • Want to patchbomb a mailing list with your latest series of changes?

    hg email qbase:qtip

    (Don’t know what patchbombing is? See Sending Changes via Email with the patchbomb Extension.)

  • Need to see all of the patches since foo.patch that have touched files in a subdirectory of your tree?

    hg log -r foo.patch:qtip subdir

Because MQ makes the names of patches available to the rest ...

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.