Mercurial and patch queues for dummies

Lately I’ve started contributing to Mozilla Firefox with some patches (yay! It’s an awesome project… consider contributing 😉 ). It was a good excuse to practice with Mercurial, the distributed revision control software used by Mozilla. I’m mainly a Git user and I have to admit I was a little puzzled at first and had to adapt to the new workflow.

In this article I will try to answer some of the questions I had during my learning phase. Well, maybe just recapping it for my own use 🙂

How can I create a new patch in the queue?

hg qnew patchname.patch

How can I update the currently active patch with the latest changes to the files?

hg qrefresh

How can I un-apply a patch from the codebase?

hg qpop patchname.patch

How can I un-apply all the patches from the codebase?

hg qpop -a

How can I remove a patch from the patch queue?

hg qpop patchname.patch
hg qremove patchname.patch

How can I sync my local repository if I’ve got some patches applied?

hg qpop -a

hg pull -u

hg qpush -a

How can I move a patch to the top of my patch queue?

hg qpush –move patchname.patch

How can I merge two patches?

hg qgoto firstpatch.patch

hg qfold secondpatch.patch


Alessio Placitelli