tags:

views:

451

answers:

2

We have a HEAD branch, and a feature branch that was created off the HEAD branch. I develop on the feature branch, and constantly merge changes from HEAD to my branch.

When I'm finished with the feature, I try to merge it back to HEAD. This is supposed to be a 0-pain operation, as all conflicts were already resolved on previous merges to the feature branch. However, it never is.

I end up copying the entire content of my branch and overwriting the HEAD branch with it. This has been the situation in Team Foundation System 2005 and 2008. Is it a bug or am I doing something wrong?

A: 

It's just the way things are, really. Assume we have two changesets on our feature branch and then merge a new changeset from the Head.

Head: Base ----------------> H1 --
           \                      \
Ftre:       -> Branch -> F1 -> F2 --> H1'

Note that H1 is a different checkin to H1', even if no changes were made (resolving conflicts)

When we now merge back to the Head from Ftre, we have changesets F1, F2 and H1' that run from Base, but Head has an additional changeset H1 after Base.

Since we know that the changesets we are merging back to Head contain all the functionality of H1, there is no problem in discarding the changes in Head (i.e. the changeset H1) and taking just the changesets from Ftre. However, you can't do this from the GUI (unless the latest version allows this) and it's been a while since I used TFS to give you the command line syntax unfortunately.

Giraffe
I would think that clicking the big "AutoMerge" button would do just that in this case.
ripper234
A: 

I've been able to overcome this flaw in 2 ways.

  1. I never merge with main or HEAD until the feature is done. (Works in cases where the HEAD change isn't important to the feature.)

  2. This one is complicated. Everytime I decide to merge HEAD to the feature branch I create what I call an integration branch from HEAD. I then do a baseless merge of the feature branches branch changeset or the first changeset on the feature branch. This puts the files together and is an argument that TFS should allow me to provide or detect a base between two siblings. (I sense this has to do with history not following branches. Team Foundation Power Toys fixes that issue.) Checkin of course to finish the establishment of the relationship. I then do a regular merge between feature branch and the new integration branch. This allows me to merge on the feature branch items in a single changeset. I then work off my integration branch and let my feature branch die. Sure I lose history on the feature branch, but I'm not sure I was interested in that anyway.

Sorry it is so complicated.