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

37,397

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

Share:
37,397
Horcrux7
Author by

Horcrux7

nothing

Updated on March 21, 2020

Comments

  • Horcrux7
    Horcrux7 over 4 years

    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.

  • Horcrux7
    Horcrux7 over 13 years
    The answer to question 2 is wrong. strip in Eclipse remove also the changeset from workspace.
  • Ry4an Brase
    Ry4an Brase over 13 years
    Yikes. I hope it gives good warnings about that. /me reminds himself why he keeps his VCS and his IDE _separate_
  • ZoFreX
    ZoFreX almost 13 years
    For the record it does not good give warnings about that, I found this question when trying to find out how to undo it. Oops!
  • Martin Geisler
    Martin Geisler over 11 years
    Use hg commit --amend in Mercurial 2.2 and later to amend (redo) the last commit.