What is the difference between hg revert and hg backout?
Asked Answered
B

1

20

Both hg revert and hg backout revert changes made by a former revision. What is the difference between the two?

Broccoli answered 7/12, 2012 at 12:23 Comment(0)
B
38

Given the history of changesets:

A --- B --- C --- D --- E
          [bad]        (*)

hg revert -r B: Stay at current revision, but update the working directory as of revision B. It has the effect of a patch that revokes the changes of C, D and E.

hg backout -r C: Update the working directory so that it contains the merge of revision C's parent (B) and the current revision, preserving the changes made in between the two revisions (working dir still contains changes of revision D and E). This has the effect of a patch applied on E, undoing the changes of only C.

You may want to edit some files if not all of C was bad. Remember to do a hg commit in any case:

A --- B --- C --- D --- E --- F
          [bad]              (*)
Broccoli answered 7/12, 2012 at 12:23 Comment(2)
Answering my own question as I couldn't find anything clear on web. Hopefully this helps others now to save some time.Broccoli
Nice answer! My "cheat sheet" explains the difference between hg update and hg revert, which might helpful as well.Accelerant

© 2022 - 2024 — McMap. All rights reserved.