The Mercurial Queues extension (mq
) provides a mechanism for
managing patches on top of a Mercurial repository and is described in detail
in Chapters
12
and 13
of Mercurial: The Definitive Guide.
This document explains how to use mq
in conjunction
with the codereview
Mercurial extension described in the
instructions for contributing to the Go project.
It assumes you have read those instructions.
To enable mq
edit either $HOME/.hgrc
(to enable it
for all of your repositories) or $GOROOT/.hg/hgrc
(to enable it for the
repository at $GOROOT
) to add:
[extensions] mq=
Since pulling, pushing, updating and committing while mq
patches
are applied can damage your repository or a remote one, add these lines to
prevent that case:
[hooks] # Prevent "hg pull" if MQ patches are applied. prechangegroup.mq-no-pull = ! hg qtop > /dev/null 2>&1 # Prevent "hg push" if MQ patches are applied. preoutgoing.mq-no-push = ! hg qtop > /dev/null 2>&1 # Prevent "hg update" if MQ patches are applied. preupdate.mq-no-update = ! hg qtop > /dev/null 2>&1
The entire checked-out tree is writable and you can use mq
,
as documented in Chapter
12
of "The Guide",
to implement your change as a single patch or a series of patches.
When you are ready to send a change out for review, run
$ hg change
from any directory in your Go repository with all of the mq
patches relevant to your
change applied and then proceed as instructed in contributing
to the Go project.
The change number reported by hg change
, preceded by a +
,
can be used as an mq
patch guard to assist in controlling which patches
are applied as described in Chapter
13
of "The Guide".
For example, the command:
for p in $(hg qapplied); do hg qguard $p +99999; done
will apply the guard +99999
guard to all currently applied mq
patches.
While you were working, others might have submitted changes
to the repository and, as explained in contributing
to the Go project, it is necessary to synchronize your repository using
hg sync
before sending your change list for review.
Because hg sync
runs hg pull -u
,
you should not run hg sync
while mq
patches are
applied. Instead
pop all your patches before running hg sync
and reapply them after
it has completed.
When reapplying the patches, you may need to resolve conflicts as described in contributing to the Go project.
You should have all of the mq
patches relevant to your
change applied when you run hg mail
.
mq
patches relevant to your
change applied when you run hg commit
.