I have a Mercurial repository. It has a patch queue (which itself is a repository containing patches). Unfortunately I have performed too many unsightly commits to MQ (with hg commit --mq
command).
If I run hg history --mq
command, it will print tons of unnecessary changesets, say, A, B, B1, B2, B3, B4, C, D .
I just want to get rid of those B1, B2, B3 and B4, but I don't want to remove the latest C and D . Just those intermediate changesets.
How can I achieve the desired?
Asked
Active
Viewed 209 times
0

Isroel Barenboim
- 11
- 4
-
I am wondering why you would want to? Once your patches are correct, wouldn't you `qfinish` them and commit them to the main repository? No one will see the patch queue history except you. – Mark Tolonen Jan 04 '16 at 22:47
-
You'd have to edit the history of the patch queue, using a patch queue for the patch queue...gets confusing. `qimport` the history you don't want, and use `qdel` or `qfold` to remove or compress the history. – Mark Tolonen Jan 04 '16 at 23:31
1 Answers
1
Assuming that there are no conflicts between the subsequent mq changesets, it's quite simple.
The mq way is to use hg qdelete PATCH-ID
with the patches you want to see removed. It is mandatory that the patches are NOT applied.
Alternatively you can use the normal hg way to edit your mq repository:
- unapply all mq changesets:
hg qpop --all
- Edit the .hg/patches/series file and remove the lines of the patches you want to see removed
- check that all remaining patches apply cleanly, best done one by one, thus do a
hg qpush
for each. Should there be any conflict fix it now. - Commit the changes to the mq repository in .hg/patches
Should you require one of the intermediate patches, check for hg qfold
and friends.

planetmaker
- 5,884
- 3
- 28
- 37
-
Look. This isn't what I really want. I'll try to explain it more clear. See, I have a repository. `~/repo`. It has nothing inside. In the `~/repo/.hg/patches` there is an MQ repository, which contains patches (say, `patch_sin`, `patch_cos`, `patch_log`, `patch_tan`). If I run `hg history` inside `~/repo`, I will always get nothing, because nothing is done directly in the repository. But if I run `hg history` inside `~/repo/.hg/patches` **or** `hg history --mq` inside `~/repo`, I'll get the list of changesets to MQ repository, not the base repository. – Isroel Barenboim Jan 04 '16 at 20:30
-
For example, I work on those patches. Say, I was sitting and writing down the code to implement `cos()` function inside the `patch_cos` patch. And I did multiple commits. So if I watch history, I'll see something like: – Isroel Barenboim Jan 04 '16 at 20:30
-
changeset: (N+2):blah-blah-hash-(N+1) user: Isroel Barenboim
date: Mon Jan 04 11:59:08 2016 +0300 summary: Final version – Isroel Barenboim Jan 04 '16 at 20:31 -
changeset: (N+1):blah-blah-hash-N user: Isroel Barenboim
date: Mon Jan 04 11:53:08 2016 +0300 summary: Attempt to debug the function N . . . changeset: 2:blah-blah-hash-2 user: Isroel Barenboim – Isroel Barenboim Jan 04 '16 at 20:31date: Sun Dec 13 11:53:08 2015 +0300 summary: Attempt to debug the function 1 changeset: 1:blah-blah-hash user: Isroel Barenboim date: Sat Dec 12 11:53:08 2015 +0300 summary: Stub for cos() function added -
I **do not** want to delete any of patches, such as `patch_cos` or `patch_tan`. What I want is to remove or somehow fold those ugly **revisions** of the patch queue from "Attempt to debug the function 1" to "Attempt to debug the function N". Only "Stub for cos() function added" and "Final version" should remain. – Isroel Barenboim Jan 04 '16 at 20:31
-
1@IsroelBarenboim, you should update your question with this expanded explanation. It is hard to follow as comments. – Mark Tolonen Jan 04 '16 at 22:42
-
Yes, please update your question accordingly. It becomes a different question with these clarifications. – planetmaker Jan 05 '16 at 08:32