Quick and dirty instructions for using mq:

mq tries to copy functionality from quilt, except that as patches are
pushed onto the stack, the files they change are committed to the Mercurial
repository.  As patches are popped from the stack, the corresponding
revisions are stripped away from the Mercurial repository.

mq is implemented as a Mercurial extension module.  These are loaded
dynamically based on entries in the hgrc files.  To install and enable
mq, you would specify the path for mq in your hgrc file.

Assuming you have a copy of mq in /usr/src/mercurial/contrib/mq, add the
following lines to your hgrc file:

[extensions]
mq=/usr/src/mercurial/mq

If you have mq installed in an official python location:

[extensions]
mq=

Mercurial will search the standard python library locations on startup.
Run hg qversion to make sure the mq module was loaded.

Important files:
.hg                -- existing hg repository
.hg/patches        -- mq patch directory
.hg/patches/series -- list of all patches managed by mq
.hg/patches/status -- list of all patches applied by mq

hg qinit          -- create the .hg/patches directory
hg qnew patchname -- create a new patch
<edit files>
hg qdiff    -- display current patch
hg qrefresh -- update .hg/patches/patchname with the current diff
<edit files>
hg qdiff    -- display current patch
hg diff    -- display only changes made since last refresh
hg qrefresh

hg qpop     -- pops patchname off the top of the stack
hg qpush    -- push patchname back on (applying it again)

For now, importing an existing patch means "cp patch .hg/patches" and
editing the series file by hand.  The patch must apply with patch -p1.  You
can edit the series file with patches applied as long as you only change
lines for patches after the top of the stack.

hg strip <rev> will remove rev and its descendants from the
hg repository.  This can be used on any hg repository even if the
.hg/patches directory does not exist.  There is no way to undo an mq strip,
use it with care.

*** Patch revision control:

You can make the .hg/patches directory a mercurial repository, and run
all of the normal hg commands on it:

hg -R .hg/patches init
hg -R .hg/patches addremove
hg -R .hg/patches commit -m "First commit"
(etc)

In general, you want to add the status file and possibly the series file
into .hg/patches/.hgignore.  These files contain state about the
current patches applied, and the belong more to the parent directory then
the patch queue dir.

hg qsave can be used to push the series file and status file onto the
patch stack.  hg qrestore will read this information and refresh the
status and series file with the saved information.  It also stores the
working directory revision number of the patch repository.

*** Command list:

hg qapplied -- list all of the patches currently applied
hg qdelete [patch] -- remove patch from series file.  (patch is not unlinked)
hg qimport patch[es] -- copy patches into the .hg/patches dir
hg qnext -- print the name of the next patch in the stack
hg qprev -- print the name of hte previous patch in the stack
hg qpop  -- pop the top patch off the stack
hg qpush -- push the next patch, applying it
hg qrefresh -- update the current patch to match the working directory
hg qrestore rev -- read status information saved at a given rev
hg qsave -- push status and series file onto the stack
hg qseries  -- list all the patches in the series file
hg strip <rev>  -- Remove rev and descendants from the repository
hg qtop -- print the name of the patch at the top of the stack
hg qunapplied -- list all the patches in the stack not yet applied
hg qversion -- print the version number

