Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 447
Horcrux7 Avatar asked Mar 20 '11 20:03

Horcrux7


People also ask

What is backout in mercurial?

Backout works by applying a changeset that's the opposite of the changeset to be backed out. That new changeset is committed to the repository, and eventually merged.

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.

How do I undo a commit in Mercurial?

You can manually trigger a rollback with 'hg rollback'. This will undo the last transactional command. If a pull command brought 10 new changesets into the repository on different branches, then ' hg rollback ' will remove them all. Please note: there is no backup when you rollback a transaction!


1 Answers

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

like image 112
Ry4an Brase Avatar answered Oct 06 '22 00:10

Ry4an Brase