With Mercurial, how can I “compress” a series of changesets into one before pushing?

The histedit extension is exactly what you are looking for.

hg histedit -o

or

hg histedit --outgoing

will bring up a list of the outgoing changesets. From the list you can

  • Fold 2 or more changesets creating one single changeset
  • Drop changesets removing them from the history
  • Reorder changesets however you like.

histedit will prompt you for the new commit message of the folded changesets which it defaults to the two messages with “\n***\n” separating them.

You can also get similar results using the mq extension, but it is a lot more difficult.

You can also use the collapse extension to just do folding, but it doesn’t provide as nice a UI and doesn’t provide a way to edit the resulting commit message. Editing the resulting commit message also allows for cleaning up the final message, which is something I always end up utilizing.

Leave a Comment