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)
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.
Use the command hg update to switch to an existing branch. Use hg commit --close-branch to mark this branch head as closed.
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.
There is only one level of rollback, and there is no way to undo a rollback. It will also restore the dirstate at the time of the last transaction, losing any dirstate changes since that time. This command does not alter the working directory.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With