Thursday, March 29, 2007

Where did my changes go? The black hole of merging...

Lately we have had some problems with files disappearing from our projects or even projects from our solutions when doing integration between our main trunk and its child branches.

Since this was causing a bit of an issue when it comes to trusting Team System to handle merges correctly I did some investigation. The conclusion I came to was that it's not a bug (as I suspected). Although since we had problems with it I decided to post about it and maybe spare someone the trouble of having to figure out why it happens.

The problem arises when you have the following chain of events:

1, Make an addition to your project file in your main trunk.
2, Make an addition to your project file in your branch.
3, Perform a merge of the changes in the main trunk into the branch.
4, Resolve the conflict by preserving target changes.
5, Make an additional change to the project file in the main trunk.
6, Perform a merge of the changes in the main trunk into the branch.

What will happen is that the second merge will happily overwrite the changes made in the branch since there are no conflicting changes (remember we resolved the first conflict by ignoring the changes from the main trunk) it will simply merge the changes which results in a copy from source since we have no conflict between the files in the merge history.

There is not much to do about this since the behaviour is by design and the only way to prevent this from happening would be to always do a content compare of a file before actually performing the merge.

So the moral of the story is that if your resolving a conflict by choosing keep target you have to really know why your doing it.

No comments:

Post a Comment