Selecting the Guards to Use

The qselect command determines which guards are active at a given time. The effect of this is to determine which patches MQ will apply the next time you run qpush. It has no other effect; in particular, it doesn’t do anything to patches that are already applied.

With no arguments, the qselect command lists the guards currently in effect, one per line of output. Each argument is treated as the name of a guard to apply.

$ hg qpop -a
patch queue now empty
$ hg qselect
no active guards
$ hg qselect foo
number of unguarded, unapplied patches has changed from 1 to 2
$ hg qselect
foo

In case you’re interested, the currently selected guards are stored in the guards file.

$ cat .hg/patches/guards
foo

We can see the effect the selected guards have when we run qpush.

$ hg qpush -a
applying hello.patch
applying goodbye.patch
now at: goodbye.patch

A guard cannot start with a + or - character. The name of a guard must not contain whitespace, but most other characters are acceptable. If you try to use a guard with an invalid name, MQ will complain:

$ hg qselect +foo
abort: guard '+foo' starts with invalid character: '+'

Changing the selected guards changes the patches that are applied.

$ hg qselect quux
number of guarded, applied patches has changed from 0 to 2
$ hg qpop -a
patch queue now empty
$ hg qpush -a
patch series already fully applied

You can see in the example below that negative guards take precedence over positive guards.

$ hg qselect foo bar number of unguarded, unapplied ...

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.