f0b0s
f0b0s

Reputation: 3097

Difference between Mercurial update and backout

What`s the difference between this 2 commands (i want to rollback to revision 1):

hg update -r 1
hg backout -r 1 --merge

(in the example tip revision is 3)

Upvotes: 5

Views: 2015

Answers (1)

brendan
brendan

Reputation: 2743

To start with, update -r 1 will undo revisions 2 and 3 in your working directory, whereas backout -r 1 --merge will undo revision 1, while keeping revisions 2 and 3. But there's a more fundamental difference:

update checks out an older revision in your working directory, whereas backout creates a new one (but normally you'd commit after the merge above). Try running glog after each of those to look at the revision graph:

before:

0 - 1 - 2 - @3

after revert:

0 - @1 - 2 - 3

after backout --merge; commit

0 - 1 - 2 - 3 - @5
     \- 4 - - - /

Because revert only affects the working directory, it is invisible to any user that clones your repository. They will end up at 3 before and after revert. Whereas after backout, they will end up at 5, which does not have the changes done by 1.

Upvotes: 11

Related Questions