tags:

views:

49

answers:

1

Made Changes in file X.java – through hg repo explorer, I see my changes.

Committed changes in X.java to local repository

I pulled changes from central repo which also included non-conflicting changes by other developer in X.java – I see chages made in X.java by other developer.

I merged two versions locally,

After merge what I am seeing is that changes made by other developer are lost (!) only for this file, and post-merge file is same as what I had committed before merge. All other files which were only changed by others are intact.

I am not sure why merge overwrote other developer’s changes, I found out that this has happened to all files which both developers have changed, merged and committed.

I am using tortoise hg for all mercurial tasks.

Can anyone help me understand what’s going on?

Also, is there anyway I can search such files which are overwritten as a result of previous merges and already committed to central repo so that I can fix them?

Thanks a lot,

*Update Added From A Comment *

I think since changes made in this file were non-conflicting i don't think mercurial launched any tool or Kdiff or asked me to manually select. I think it automerged itself. If at all which I am not 100% sure, mercurial might have marked file as "U" (Unresolved) which after checking non-conflicting changes, I might have chosen "Mark conflict as resolved" option. I remember me doing that for couple of files not sure if I did that in this case. so only two possibilities are 1. Mercurial might have auto-merged without my intervention 2. I might have chosen "Mark as resolved" option. – alwaysLearning

+1  A: 

Mercurial will do a pre-merge when you ask it to merge, but it is very conservative in doing so and certainly won't leave code on the floor, so it didn't "auto merge" this for you.

Your second action 'mark as resolved' would perfectly describe the results you have. Using mark as resolve (hg resolve --mark from the command line) tell's mercurial: "The working copy on disk is the perfect marriage of those two files, and should be what's promoted on to the merge changeset". If you do that before actually merging those files, you'll have nothing but the left parent of the merge in the resulting file, which again sounds like what you have.

Fortunately you can always re-do a merge:

hg update -r leftParentRevisionId
hg merge rightParentRevisionId
..do your manual merges as necessary.
hg commit -m 'merged left and right'

Unfortunately, if people have already done further work based on the incomplete merges you've previously pushed out you'll need to move that work over too.

In general remember that merging is just as much a part of coding as typing. It's a conscious human action and deserves care and code-review.

Ry4an
I think since changes made in this file were non-conflicting i don't think mercurial launched any tool or Kdiff or asked me to manually select. I think it automerged itself. If at all which I am not 100% sure, mercurial might have marked file as "U" (Unresolved) which after checking non-conflicting changes, I might have chosen "Mark conflict as resolved" option. I remember me doing that for couple of files not sure if I did that in this case. so only two possibilities are 1. Mercurial might have auto-merged without my intervention 2. I might have chosen "Mark as resolved" option.
alwaysLearning