3

We have a project that is in TFS 2010 and was incorrectly branched. We want to fix it. This is the current structure we have:

  • Development
  • Integration
  • Main

The problem is that Main is a branch of Integration, which in turn is branch of Development, when it should be the very opposite.

In other words, first it was created Development, then branched Integration and then Main.

Now all three branches have same code (were merged).

So, Is it possible to fix the TFS references to have the right flow: Main -> Integration -> Development?

pointnetdeveloper
  • 224
  • 1
  • 3
  • 7
  • 1
    The relationships are more important than the order of branch creation. For all intents and purposes Dev -> int -> main is the same as Main -> int -> dev. You can always reparent the branches is its a problem but practically there's no difference – James Reed Aug 18 '13 at 14:22

1 Answers1

5

As far as I know, there is no way to make this change behind the scenes. The problem you have in hand is that the Development and Main branches are out of place. Easiest thing to fix this would be to rename the "Development" branch as "Main" and vice-versa or Use the REPARENT option as shown at the end of the answer.

Am assuming that in your case since you have only one DEV branch (it wouldnt be possible to have more than 1 dev with the current branching structure), the development for the next release wont happen till the current release is out in production right? In that case, you can wait till the end of the current release and then rename the branches, so that all the 3 branches are in sync before the rename.

(Keep in mind that "Rename" changeset would affect all the files and folders in your branch, and from the comments below I can understand that it can be very problematic if you do it at the wrong time. Choose your time very wisely, make sure that you dont have any changes pending between the branches and it's just the "Rename" changeset thats pending between branches)

Another approach would be to use REPARENT. After a great discussion in the comments below, I tried the options myself and the best way to fix this would be to use the "Reparent" option. I tried this out myself by creating three different branches. You can do the following to fix it:

  1. In Visual Studio, Click on the Main branch -> then File -> Source Control -> Branching and Merging -> Reparent. Select "No Parent" and then click "Reparent"

  2. Click on the INT branch -> then File -> Source Control -> Branching and Merging -> Reparent. Select "Main" and then click "Reparent".

  3. Click on the DEV branch -> then File -> Source Control -> Branching and Merging -> Reparent. Select "INT" and then click "Reparent".

Isaiah4110
  • 9,855
  • 1
  • 40
  • 56
  • 2
    1. Renaming branches will cause a [whole host of problems](http://stackoverflow.com/a/17819821/568475) 2. pointnetdeveloper can create multiple dev branches, by branching them from "Int". 3. Creating new branches is unnecessary. There isn't anything wrong with the relationships between the branches, Dev -> int -> Main is effectively the same as Main -> int -> Dev. the only practical difference is that the branching visualisation will show things the wrong way round. This can be fixed using "reparent" – James Reed Aug 19 '13 at 10:21
  • 2
    I agree that renaming can cause problems, but if you do it at the right time it should be just fine. Not in the middle of a release, but at the beginning when everything is in sync and we have just the "rename" changeset. In that case, a merge would ensure everything works good. Your link which says a branch after rename will cause "baseless merge" is wrong. Only the items where the content differs between the source and target since the last merge will be baseless merged, not the entire branch! – Isaiah4110 Aug 19 '13 at 14:08
  • 4
    I agree that even though names are different, relationship is the same. But for all intents and purposes at a working environment, you cannot keep "Main" as "DEV" and vice-verse. This could create lot of confusion among developers. "Reparent" option again has to deal with a baseless merge. So I dont know how that is better – Isaiah4110 Aug 19 '13 at 14:58
  • Your comment makes no sense, it's the name of the branches and the relationships that are important. Not the parent child relationships. Main is main because that's what it's called. "Main as dev" makes no sense at all. Reparent has nothing to do with baseless merges, it just changes the parent child relationships for the visualisation it doesn't affect the way a merge will be performed in any practical way – James Reed Aug 19 '13 at 20:42
  • 1
    Sir please I know you have enough knowledge to understand what I am saying! Main is Main because that's what it is called. I agreed to that long time back. But what I am saying is in a working environment "Main" cannot be called "Dev" and "Dev" cannot be called "Main", that will only create confusion among everyone. Period! – Isaiah4110 Aug 19 '13 at 21:08
  • And yes I was wrong about the Reparent (baseless merge), since these are branches which already have a relationship, no merges happen here. But in the case of creating a parent to a branch where there is no relationship, a baseless merge needs to happen first. – Isaiah4110 Aug 19 '13 at 21:29
  • And no one is suggesting the dev is called main. I don't understand your comment. What I am saying is that the merge relationship is correct. Dev -> int -> main is the correct relationship so a baseless merge is not required. Renaming branches is not required. The only thing the original questioner need to do is reparent the branches so that the order in the visualisation tool is correct. As long as the developers continue to check code in to dev, and code is merged from dev -> int -> main then there isn't a problem. – James Reed Aug 19 '13 at 22:50
  • My point is that branch renames and baseless merges can and usually do have unintended consequences and should be avoided. They should only be used as a last resort. The reason I'm pursuing this so doggedly is because I've seen the problems that this can cause first hand and its not pretty. This isn't intended to be a personal attack at you, I'm just trying to save the original questioner and others that read this from problems in the future – James Reed Aug 19 '13 at 23:02
  • None taken personally, we are trying to be constructive here! :) Am sorry I might be missing something very obvious here, I just dont understand this part "As long as the developers continue to check code in to dev, and code is merged from dev -> int -> main then there isn't a problem." For me (code is merged from dev -> int -> main) is crux of the problem. Anyways, for the purpose of saving both of our time, I will leave it here. I have edited my answer a bit, look through and let me know. – Isaiah4110 Aug 20 '13 at 13:17
  • I understand that you have had a bad experience with branch renames, but if you cannot avoid and need to do then if you do it at the right time as in when all branches are in sync, it shouldnt be much of a headache. – Isaiah4110 Aug 20 '13 at 13:17