What is the difference between rollback, backout and strip in the Mercurial Eclipse plugin?

EclipseMercurialRollback

Eclipse Problem Overview


What is the difference between the menu items rollback, backout and strip in the Mercurial Eclipse plugin?

Can I delete the commit in the local repository without modify the files in my workspace with one of this 3 commands?

Or is there another solution how I can commit and push a fix on another part of the project? My current work is not finish and I can not push it. But I must checkin a quick fix for another part of the project.

The only solution that I see is to create a second workspace. But this look like a overkill for me.

Eclipse Solutions


Solution 1 - Eclipse

These commands all come from Mercurial itself, and there are plenty of good compare/contrast posts for them. However, here they are in brief:

  • rollback: one-level undo. Will undo the last pull or commit (can be dangerous)
  • backout: create a new commit that is the inverse of a given commit. Net effect is an undo, but the change remains in your history.
  • strip: remove (destroy) changes from history. Removing a changeset also removes all of its children, so it can only be used to truncate history, not remove a slice.

All three are very well described here: http://www.selenic.com/mercurial/hg.1.html

To your question 2, you could use strip to remove the most recent commit and it won't alter you working directory diles.

To your question 3, you can easily make changes on another part of this project:

hg commit -m 'commit your half done work'
hg update OLDERCHANGESET # your working directory now is without the half-done-work
.. do that quickfix ...
hg commit -m 'quickfix'
hg push tip # this pushes the tip revision (latest) and its ancestors, but the half-don't work isn't an ancestor so it doesn't get pushed
hg update HALFDONEWORK # you can find the right revision number using "hg heads"

That's call an "anonymous branch" and it's a very common way to work. You do end up committing the half-completed feature, but you can resume it later and you don't have to push it.

This has a great explanation of anonymous branches: http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/#branching-anonymously

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHorcrux7View Question on Stackoverflow
Solution 1 - EclipseRy4an BraseView Answer on Stackoverflow