Branching and Merging


Branching and Merging are two important functions of any source control system. During the process of building a piece of software, you may find the need to release a stable version for Beta testing, or you may want to work in parallel on bug fixes without interrupting the main process of development process. In order to better manage this process, you can create many development versions of the same code base (called branching) and re-integrate them into the Main tree (merging). You might have heard of the terms Forward Integration and Reverse Integration. Here is what they mean in the context of branching and merging. Forward integration is the process of merging changes from the main development line into a branch. Reverse integration is the complete opposite — you integrate or merge the changes in your branches back down to the Main branch. Figure 20-15 shows a few common scenarios you might encounter where you would need branching and merging.

image from book
Figure 20-15

A branch was created from version 1.0 of the application to create a release or preview version for customers or beta testers. In version 1.1, a critical bug was found and a separate branch was created with incremental fixes. The fixes were completed in version 1.1.1.2 and reintegrated into version 1.4 of the main branch.

Branching

Branching enables you to create copies of your source files, but also maintains a history of your changes in case you want to do a merge in the future. You can use the Source Control Explorer to navigate between different branches. To create a branch, simply right-click your solution in the Source Control Explorer and select Branch from the context menu — the dialog box shown in Figure 20-16 will appear on-screen.

image from book
Figure 20-16

The main branch dialog box has several options: The Target field enables you to set the name of your branch. The Branch From version option enables you to select which version of the branch you would like to use (the latest version or an older version). You can opt to create a local copy of a branch by selecting the Create Local Working Copies for the New Branch option. It will download the newly created branch files to your workspace.

Everyone has his or her own way of organizing source code. One of the popular models is the development/main/release model, as shown in Figure 20-17.

image from book
Figure 20-17

As you can see in the figure, development, main and release is running in parallel. Once work is stabilized in development, it is integrated into the main branch. As code moves up to the release branch, its quality increases to the point it can be released publically.

Merging

Merging means to combine changes from two or more branches. This functionality is very useful for teams of developers working in parallel. During a merge, many changes are integrated, including add/edit/delete operations. If there are merge conflicts between branches, you can resolve them in a variety of ways, including the use of a diff-merge tool. There are two ways you can merge files: using the Source Control Explorer and via the command line. You can also specify whether you want to incorporate all the changes or just specific versions.

When you merge, Team Foundation version control will use the history behind the scenes to try to branch files and folders that have been added to another branch. Changes that don't exist in the target branch will be merged. If any of the files or folders have been changed in the target branch, a merge conflict will occur.

You can access the Merge Wizard by right-clicking the folder (in the Source Control Explorer) that you want to merge. If you click the Merge option on the pop-up menu, you will be presented with the Source Control Merge Wizard, as shown in Figure 20-18.

image from book
Figure 20-18

The Version Control Merge Wizard will present you with a preset list of target branches you can merge to and give you the option to commit all changes in the source branch or only selected changes. Once you click the Next button, you will be presented with the option to select the changes you want to merge, as shown in Figure 20-19.

image from book
Figure 20-19

Once all of the options have been set, all you need is to click the Finish button to execute the merge process.



Professional Visual Studio 2005 Team System
Professional Visual Studio 2005 Team System (Programmer to Programmer)
ISBN: 0764584367
EAN: 2147483647
Year: N/A
Pages: 220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net