views:

218

answers:

2

alt text

Revision 107 accidentally merged away all the changes from 100-106

Revision 108 was a hg revert --all -r 106, followed by hg commit, which was probably the wrong thing to do, since instead of merging the branch where I made all the changes, I've encompassed all the changes into one changeset with no description or history.

A) How should I have gone about merging the branch in the first place?

But more importantly:

B) How do I go about merging the branch now?

+1  A: 

If at all possible, back-up the repository, so that you can experiment safely.

This command will undo the last transaction:

hg rollback -h

This command might help you to undo your merge and revert:

hg backout -h

This command will recover your working directory to a previous state without affecting the repository:

hg revert -h

The -h option in each case gives you the help for the command. Remove the -h option when you are ready to apply the command.

My first experiment would be:

hg rollback
hg merge -r 106

The plan being to get back to revision 107, which looks like a successful merge of the head containing changesets 95 and 96, and then to merge in the head containing changesets 97, 100 - 106.

richj
+2  A: 

If you've not yet pushed the repo anywhere off your box you have an easy fix:

   cd ..
   hg clone -r 106 current newcurrent
   cd newcurrent
   hg pull -r 97 ../current

now newcurrent is a repo that looks exactly like your old one did before 107 and 108 happened.

To merge those two, just do:

   hg update  # which gets you to tip
   hg merge   # which merges in the other head and forces you to make choices

It's not clear what you did wrong in creating 107, so I don't know how to suggest a change in practice, but it should be a simple matter of merging. Accidentally eliminating all the changes in one branch should have been hard.

Ry4an
Thanks!This did the job.
Autopulated