Version Control Walkthrough (Branching Strategies) Part 1 – MAIN Only and Simplicity Rules


This level 200 walkthrough series is a companion for the Branching Strategies guidance, which aims to provide insightful and practical guidance around branching strategies with Team Foundation Server. Using a simple sample solution we walk through one possible scenario of starting with no branching strategy and ending with the Servicing and Release Isolation strategy.


Prepare your working environment (sandbox)

This is a once-off environment setup, which we will re-use in future posts. Please do NOT use your production environment. Use a demo or test environment, or get started for FREE on Visual Studio  Online.

Create a Team Project

  • Create a Team Project called BranchingScenarios.
  • Select the process template of your choice.
  • You do not require a SharePoint portal.
  • Select Team Foundation Version Control for your Source Control.
    image

Create your workspace

  • Connect to the new team project BranchingScenarios.
  • Select configure your workspace mappings to get started.
    image
  • Map the workspace to a path, for example, c:\HOL\BranchingScenarios.
    image
  • Select Advanced… and name your workspace HOL.
  • Select Map & Get.
  • Go to Source Control Explorer.
  • Change your workspace to HOL.
    image
  • Create a folder main in c:\HOL\BranchingScenarios through the Source Control Explorer.
    image

Download and check in the sample code

  • Download the sample code from https://aka.ms/hol-bs1.
  • Unzip the sample project to the c:\hol\BranchingScenarios\main.
  • Open the solution 6_MEF in c:\hol\BranchingScenarios\main.
  • Select OK when you get the following Visual Studio 6.0 projects warning.
    image
  • Explore the sample solution.
  • It is a console based sample solution and we will use the Debug Command parameter to define test data, i.e. 1 1 + to add 1 and 1.
  • Ensure it builds without any errors.
  • Right click on the solution in the Solution Explorer, and select Add Solution to Source Control…
    image
  • Right click on the solution in the Solution Explorer, and select Add Solution to Source Control…
  • Right click on the 6_MEF project in the Solution Explorer and select Properties.
  • Select Debug tab and define the following command line arguments 1 1 +
    image
  • Build and run the program (F5) and verify you see the following result.
    image
  • Right click on the solution in the Solution Explorer, and select Check In.
  • Enter a check-in comment and click Check In button to commit the code to Source Control.
    image

Wow … we are done with the preparations Smile


Developing on Main

Goal

Explore the Main Only branching strategy. We recommend the strategy and the avoidance of branch and associated merge strategy, and are using this strategy for most new ALM Ranger projects.

Context

Your team needs to implement the DIVIDE feature, has no need for isolation (yet) and is comfortable with using labels to indicate milestones. By using the Main Only strategy you avoid the need for branching and subsequent need for merging, which minimizes maintenance complexity and associated cost.

image

NOTE

In a real-world you need to implement BVT (Build-Verify-Test) strategies, such as a gated build and unit tests, to protect the quality of the main and other branches.

  • To start we label our latest code, we just checked in, as v1.0.
  • Right-click on the main folder in the Source Control Explorer, select Advanced and Apply Label. 
    image
  • Define a name, comment and select the Latest Version.
    image
  • Right click on the 6_MEF project in the Solution Explorer and select Properties.
  • Select Debug tab and define the following command line arguments 4 2 / 
    image
  • Build and run the program (F5) and verify that the calculator fails as it lacks this feature. 
    Sample_Div_error 
  • Add class CalculationExtension_Div to the project and the division logic by writing out the class or copy-paste and edit from the *_Add class.
    Sample_Div_Code
  • You must define the ExportMetadata symbol, the class name and the division.
  • Build and run (F5) the solution.
  • Verify your vision calculation now passes. 
    Sampel_Dix_OK
  • Feature implemented and tested successfully by developer.
  • We can now check in the changes without compromising the main folder quality.
  • Check in the code changes by right-clicking on the main folder in the Source Control Explorer and selecting Check In Pending Changes.
  • Right-click on the main folder in the Source Control Explorer, select View History and take note of the changesets. You should have one for the initial import and one for the division feature. 
    image
  • Right-click on the main folder in the Source Control Explorer, select Advanced, Apply Label and create a v1.1 label.
  • Right-click on the main folder in the Source Control Explorer, select View History and then select the Labels tab.
  • You now have two labels specifying milestones on our main branch.
    image
  • Right-click on any of the labels.
  • Note the edit and delete options for labels, which makes them mutable and therefore not reliable for auditing.
    image

Optionally convert main folder to main branch

This is an optional step and is automatically performed when you create branches off main. ALM Rangers frequently use the TFS Branch Tool utility to implement their version control environment, which automatically performs this step as part of the configuration.

  • Right-click on the main folder and select Branching and Merging. 
    image
  • Note that we can Branch, Merge and Convert to Branch.
  • Right-click on the main folder and select Branching and Merging, Convert to Branch.
  • Optionally add a description and then select Convert.
  • Notice that the folder icon has changed into a branch icon.
    image
  • Right-click on the main branch and select Branching and Merging.
  • Note that Convert To Branch has vanished, but View Hierarchy and Reparent appeared.
    image
  • Select View Hierarchy to view the single (main only) node.

Review

We explored the Main Only branching strategy and the implications of promoting the main folder to a branch. We worked in only one place, the main folder and used labels to bookmark versions of the code base.

In this walkthrough we performed:

  • 0 branches
  • 0 merges
  • 2 labels

Next up: Version Control Walkthrough Part 2 – Development Isolation.


Please send candid feedback!

image

We need your candid feedback. Here are some ways to connect with us:

  • Add a comment below.
  • Contact us on our blog.

References



A special thank you to everyone who laid the foundation this and ither version control guidance: Anil Chandr Lingam, Bijan Javidi, Bill Heys, Bob Jacobs, Brian Minisi, Clementino de Mendonca, Daniel Manson, Jahangeer Mohammed, James Pickell, Jansson Lennart, Jelle Druyts, Jens Suessmeyer, Krithika Sambamoorthy, Lennart Jansson, Mathias Olausson, Matt Velloso, Matthew Mitrik, Michael Fourie, Micheal Learned, Neno Loje, Oliver Hilgers, Sin Min Lee, Stefan Mieth, Taavi Koosaar, Tony Whitter, Willy-Peter Schaub, and the ALM Community.


Comments (0)

Skip to main content