The Mercurial Queues tutorial is terrible for this use case. All the examples that I saw suggest that you have yet to commit, and you are updating one patch. In most cases, this is not the case, and you have 2 or 3 commits that you want to insert or modify in some other way.
Let's say you have a story like this:
The first example - squash commits A, B and C. The first init mq:
$ hg qinit
Now we need to import the commits A, B, and C into the patch queue. Assume they are the last 3 commits. We can use the “-N” syntax to import them like this:
$ hg qimport -r -3:-1
This means that importing as patches of 3 patches returns to the last commit. You can check the status of these patches with hg qseries . It should show something like this:
$ hg qseries 101.diff 102.diff 103.diff
If the numbers 101, 102, and 103 correspond to the local revision numbers of commits A, B, and C. Now these corrections are applied, which means that the changes they describe are already in the working copy. You can get rid of working copy changes and remove them from the commit history by saving them only in patch form using hg qpop . You can say hg qpop; hg qpop hg qpop; hg qpop to swap C and B changes from the stack, or specify a patch for "pop to". In this case, it will be something like this:
$ hg qpop 101.diff now at: 101.diff
Now you have corrections for commits B and C in the patch queue, but they are not applied (their changes were "lost" - they exist only in the patch queue area). Now you can add these patches to the last, i.e. We create a new commit that is equivalent to the sum of the changes A + B + C.
$ hg qfold -e 102.diff 103.diff
This will show your editor so that you can change the commit message. By default, a message will be a concatenation of commit messages for changes A, B, and C, separated by asterisks. It's nice to note that hg qfold will fill in patches if you use bash and gain access to the hg-completion script. This leaves a story like this, where A + B + C is the only commit, which is a combination of 3 patches that interest us:
Another use case is if we have the same story as before, but we want to remove patch B and merge A + C. This is actually similar to the above. When you go to the qfold step, you simply add up the last commit, not the last 2 commits:
$ hg qfold -e 103.diff
This leaves the change for B in the patch queue, but it does not apply to the working copy, and its commit is not in the history. You can see this by doing:
$ hg qunapplied 102.diff
Now the story looks like where A + C is one commit that combines the changes of A and C:
The final use case might be that you only need to apply commit C. You would do this by running qimport as described above and you would pull out all the fixes you don't need:
$ hg qpop -a
The -a flag means turn off all patches. Now you can only apply the one you need:
$ hg qpush 103.diff
This leaves you with this story:
Once you are done with all this, you need to finish the job in line. This can be done with:
$ hg qfinish -a
So here we are. Now you can run hg push and do just what you want, or hg email patch in the mailing list.