This project has moved. For the latest updates, please go here.

What Does 'Convert to Branch' Do?

Nov 9, 2010 at 2:07 PM

Can anyone provide some insight onto what the 'Convert to Branch' does and when I should or shouldn't use it?

From the ranger docs I see some of the 'Main' folders have been converted to a branch but the Development and Release folders at the same level as Main have not been converted to a branch. Figure 3 from page 6 of the TFS_Branching_Guide_Main_2010_v1.pdf shows the following branch depiction, under Develpoment and Release are the same folder names that have been converted to a branch

MAIN (is converted to branch)

DEVELOPMENT (not converted to branch)

    DEVELPOMENT (is converted to branch)

        BIN......

RELEASE (not converted to branch)

    RELEASE (is converted to branch)

        BIN.....

 

When I branch from a 'converted to branch' folder why would it not already be a 'converted to branch' type folder.....as it is a branch? i.e. if I Branch MAIN above to DEVELOPMENT/DEVELOPMENT the second DEVELOPMENT folder is not defaulted to a 'Converted to Branch' folder.......yet it is a Branch.

Convert to Branch seems an odd name to me as in my eyes you don't have a Branch until you create a branch. Why can I have a folder 'converted to Branch' that actually has no branch?

 

Any clarification would be greatly appreciated.

Developer
Nov 9, 2010 at 2:38 PM

In VS 2008, TFS did not have a concept of branches as *first class objects*. These were introduced with TFS 2010.

In TFS 2008, therefore, you could have folders that were branched to other folders. In TFS 2010, when you create a folder it can become (converted to) a branch in a number of ways. When you branch a folder to create a child branch, both the source and target of the branch operation are converted to first class branches. A major benefit of branch objects is that you can visualize branches in TF 2010 but you cannot visualize folders.

In you example above, where you branch Main to Development/Development (the target branch cannot already exist). A new branch *Development* is created within a containing folder *Development*. Since the Development/Development (folder/branch) branch did not exist, it was created, not converted from a folder.  In our example above, Release/Release (folder/branch) is anothe example of a folder (Release) containing a branch (Release)

You can also take any folder in your hierarchy and convert it from a folder to a branch. Or you can take a branch and convert it to a folder. What you cannot do, however, is create a nested branch scenario. A branch in TFS 2010 cannot contain another branch undereath it. Release/Release cannot both be branches (although they could be folders. Similarly Development/Development cannot both be branches.

In VS 2008, it was difficult to ascertain which folders were also branches (there were no branch objects). Folders, and branched folders all had folder icons associated with them in Source Code Explorer. In TFS 2010, the branch icon is separate and distinct from the folder icon. When a folder is converted to a branch, it is no  longer technically a folder.

Hope this helps,
Bill Heys
VS ALM Ranger

Nov 9, 2010 at 3:33 PM

Am I correct in stating that converting a folder to a branch just changes the folder icon to a branch icon and is simply a visual notation with nothing else happening?

 

Developer
Nov 9, 2010 at 3:48 PM

Mike,

No, changing the icon is only a small part of the picture. You can only do branch visualization on branches (witht the branch icon), not with folders (with the folders icon)

Bill

Nov 9, 2010 at 4:07 PM

Bill,

Thanks for the responses....and all of the other support here as well.... but my thick skull just can't seem to get over the name 'Convert to Branch'. A branch, is created by copying one set of 'data' to another set, the output of 'Convert to Branch' does not result in another set of data.

I'm still not clear, outside of visualizations and the ability for the IDE to display graphical information what effect does a folder converted to a branch have on the actual branching process? It seems I do not have to Convert to Branch, in the above example what would happen if MAIN had not been converted to a branch?

 

Mike

 

Developer
Nov 9, 2010 at 5:41 PM

Mike,

In this case, Converting a folder to a Branch *converts* the type of object from folder to branch (it does not result in another set of data, as you note.). Converting a folder to a branch enables a lot of new branch functionality in TFS 2010 such as branch visualizations, tracking changesets, etc.

As I noted above, by default, when you start with a folder and branch this folder to a new branch you have the option to convert the source and target folders to branches as part of the branching operation. If you uncheck this option, Main and Development/Development will remain as folders. Keeping them as folders, does not change the branching process, per se. But it does prevent you from doing the branch visualizations that are available only on branch objects.

In fact, when you create a  branch, there is no copying of data from the source branch to the new target branch. TFS only keeps a delta (what has changed). So only when you make changes to a file in the new branch and check it in will you begin to create data (behind the scenes) under the new branch.

You can't see this in the IDE - becuase when you open a file in the new branch you are seeing the current state of the file. But behind the scenes TFS does not store the complete before and after of this file ... just the changes.

Regards,

Bill Heys

Nov 9, 2010 at 6:12 PM
wheys wrote:

As I noted above, by default, when you start with a folder and branch this folder to a new branch you have the option to convert the source and target folders to branches as part of the branching operation. If you uncheck this option, Main and Development/Development will remain as folders. Keeping them as folders, does not change the branching process, per se. But it does prevent you from doing the branch visualizations that are available only on branch objects.


Ok I am clear now, 'Converting to Branch' has nothing at all to do with the actual code branching process itself. Above in blue again shows my confusion around this 'Convert to Branch' option, creating a branch....creates a branch regardless of whether I choose convert to branch or not. If I choose to also convert to branch it enables various GUI viewing capabilities that in no way effect the physical branching process itself.

While I do not have a better name for it I believe that 'Convert to Branch' is a very misleading term for those new to branching.

Seems to me that the ability to visually differentiate between a source folder and a folder resulting from a branch operation would be something you would always want. Are there reasons you would not want to 'Convert to Branch'?

Thanks for your help.

Mike

Developer
Nov 9, 2010 at 6:34 PM

Mike,

Convert to Branch - as its name implies - converts a folder object to a branch object, thus enabling branch visualizations for that branch.

You also have (not as easy to find) Convert to Folder - which converts a branch back to a folder.

If you do not select the option to convert source and target folders to branches, then after the branch operation (assuming you are branching from a folder, not a branch object), you will end up with *branched folders*. They will be *branches* with functionality similar to that in VS 2008, but without visualizations. With the option selected you will start from a folder and end up with two first-class branches - with visualizations enabled.

I can't think a better term than Convert [folder] to Branch. That is precisely what is happening.

As for your *editorial* comment about always wanting to select this option - I agree - absolutely. But there are times when you may want to restructure your folder/branch hierarchy when it might (rarely) be preferred to have a folder (or branched folder) rather than a first-class branch. Nested branches (whcih are not allowed) might be one case where if you convert a branch to a folder (branched folder), you might be able to nest a branch under it, or make a different folder in the hierarchy into a branch. These are admittedly edge cases.

Bill

Developer
Nov 9, 2010 at 6:43 PM

Mike,

As an example of my points above. I started with a new team project. I add a *folder* called Main.

I then branch Main to Development/Development and choose the option to convert folders to branches. Both the source and target folders become branches and have the branch icon in SCE. This option only appears when the source of your branch operation is a folder (not a branch).

Next I create another new folder called Main2. I then branch Main2 to Development/Development2 and choose to deselect the convert folders to branches option. Both the source and target folders remain as folders (branched folders) in SCE. If you look at the properties of a branch and compare that to the properties of a folder, they are quite different.

Next I branched from branch Main to Main2/Main3. This operation is allowed becuase Main2 is a branched folder. Main and Main3 are branches.

Next I try to convert Main2 from a folder to branch (convert to branch). This does not work because this folder contains a branch underneath it.

Next I convert Main2/Main3 from a branch to a folder (this option is not easy to find. It is under File -> Source Control -> Branching and Merging, but not under the Branching and Merging menu when you right-click on Main2/Main3

Now Main2 and Main2/Main3 are branched folders. I can now make Main2 a branch (Convert to Branch)

So now Main2 is a branch and Main2/Main3 is a branched folder.

Regards
Bill Heys