I run into the following issue all the time with Mercurial, and it's very annoying:
- I'm at some revision A.
- I have local changes, which I meant to commit or amend on top of A, but haven't yet.
- I want to go to some revision B, but I forgot that I had local changes!
- I do
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
- fix the merge conflicts at B
- go back to A, getting merge conflicts again
- fix the merge conflicts again at A
- commit my changes at A and go back to B
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.
hg update
to dohg update -c
to avoid this. However, I ran into it today, and this approach worked perfectly to fix it. Thanks very much! – Jiujitsu