I run into the following issue all the time with Mercurial, and it's very annoying:
hg update B
. Mercurial "helpfully" tries to rebase my local changes to apply on top of B. This typically results in conflicts, and it now asks me to fix the conflicts.However, I don't want to fix the conflicts! I don't want my local changes to apply on top of B at all. I want them to stay at A, either as a new commit just after A, or amended into A, as the case may be.
Is there a way I can recover from this state? The only way I know how is to
This is a lot of work, and it's pointless. I shouldn't have to rebase my local changes to apply on top of B, only to rebase them again to apply on top of A.
If there's no better way to recover from this mistake, is there a way to get hg
to refuse to do an update when you have local changes? I never want to do that - if I wanted that I'd just commit the local changes and rebase them on top of B.
You can undo all uncommitted changes by doing: $ hg revert somefile # undo uncommitted changes to this file $ hg revert -a # undo all uncommitted changes to all files.
hg revert changes the file content only and leaves the working copy parent revision alone. You typically use hg revert when you decide that you don't want to keep the uncommited changes you've made to a file in your working copy.
If you want to 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 .
Description. The hg command provides a command line interface to the Mercurial system.
Getting the dirty files back after updating somewhere and back is a bit tricky. The "trick" is to make sure that your working copy has the dirty files after the first update.
So after you do
hg update $SOMEWHERE
and discover the mess because Mercurial begins opening merge tools, calmly close the merge tools and then run
hg resolve --unmark --all
hg resolve --all --tool internal:local
All files that were merged because you had changes in them will now look like they did in your dirty working copy. This includes files that were merged cleanly and files you were prompted to merge. Updating back is now possible:
hg update $BACK
hg resolve --unmark --all
hg resolve --all --tool internal:local
You should now be back to where you started. If you modified the files after the first update, then it is the modified version you see after the second resolve. This is why you will want to resolve the files after the first update.
hg update -c
will abort the update if you have any uncommitted changes.
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