Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Let's say I have a local and a remote Mercurial repository. Now, I start working on a feature. I work on it, and when I think it's done, I commit the changeset. Testing it a bit more, I find that I could further improve this feature by tweaking something in the code. I make the change and commit. 20 minutes later, I find there's a bug in this new feature, so I fix it and commit that too.

I now have 3 changesets that I would really like to push to the remote repository as one changeset with message "Implementing feature X", for instance.

How can I do this without much hassle? I believe I could do it with patches, but it seems like a lot of work.

like image 318
Lucas Avatar asked Jul 29 '09 14:07

Lucas


People also ask

How do I revert a changeset in Mercurial?

Revert changes already committed To backout a specific changeset use hg backout -r CHANGESET . This will prompt you directly with a request for the commit message to use in the backout. To revert a file to a specific changeset, use hg revert -r CHANGESET FILENAME . This will revert the file without committing it.

What is hg command?

The hg command provides a command line interface to the Mercurial system.

What is mercurial changeset?

A changeset (sometimes abbreviated "cset") is an atomic collection of changes to files in a repository. It contains all recorded local modification that lead to a new revision of the repository. A changeset is identified uniquely by a changeset ID. In a single repository, you can identify it using a revision number.


2 Answers

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.

like image 116
Stefan Rusek Avatar answered Oct 01 '22 14:10

Stefan Rusek


How about the Collapse Extension?

like image 42
Steve Losh Avatar answered Oct 01 '22 12:10

Steve Losh