Version Control Walkthrough (Branching Strategies) Part 3 – Feature Isolation … a special!


Continued from Version Control Walkthrough (Branching Strategies) Part 2 - Development Isolation … welcome branching we explore feature isolation.

Goal

Explore the Feature Isolation strategy which introduces one or more feature branches from main, enabling concurrent development on clearly defined features, which can be merged and released as needed.

Context

As before you need isolation, but you have a need to develop clearly defined features Mod and Power, with flexibility in terms of which when the features are released into production. Whether you implement another development branch or named feature branches is your choice, whereby we will implement the following hybrid-model for this exercise as shown below:

image

A different strategy could be to branch off the dev branch tying the features and their implementation to the dev branch instead. This strategy would use the development branch as an integration branch, merging all features to the parent.

image

Create Feature Branches

Create Feature Branches

  • Right-click on main branch in Source Control Explorer, select Branching and Merging, Branch.
  • Define target as $/BranchingScenarios/featurePOWER.
    image
  • Consider concept of folders for organizing branches when working with feature branches, for example $/BranchingScenarios/features/featurePOWER.
  • Select Branch and confirm “Continue to branch?” dialog with Yes.

Create MOD feature branch

  • Right-click on main branch in Source Control Explorer, select Branching and Merging, Branch.
  • Define target as $/BranchingScenarios/featureMOD or $/BranchingScenarios/features/featureMOD if you wish to organize your feature branches further.
  • Select Branch and confirm “Continue to branch?” dialog with Yes.

Get latest and view hierarchy

  • Right-click on BranchingScenarios folder in Source Control Explorer, select Get Latest Version.
  • Right-click on main branch in Source Control Explorer, select Branching and Merging, View Hierarchy.
    image

Create MOD Feature

Implement feature

  • Open the 6_MEF.sln solution in the featureMOD branch.
  • Add class CalculationExtension_Mod and the Mod logic by writing out the class or copy-paste and edit from the *_Add class.
  • You must define the ExportMetadata symbol, the class name and the Mod.
    image

Test feature

  • Right click on the 6_MEF project in the Solution Explorer and select Properties.
  • Select Debug tab and define the following command line arguments: 5 2 %
  • Build and Run (F5) the solution.
  • Verify that your mod feature works as shown.
    image

Check-in

  • Check in your changes to the featureMOD branch.

Create POWER Feature

Implement feature

  • Open the 6_MEF.sln solution in the featurePOWER branch.
  • Add class CalculationExtension_Pow and the Power logic by writing out the class or copy-paste and edit from the *_Add class.
  • You must define the ExportMetadata symbol, the class name and the Power feature.

image

  • The code above is not the most optimal and you are welcome to improve the sampleSmile

Test feature

  • 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 ^
  • Build and Run (F5) the solution.
  • Verify that your power feature works as shown.
    image

Check-in

  • Check in your changes to the featurePOWER branch.

Context – Intermission

As shown below, we have a stable main, a development branch with unknown activity and the two new features all ready to go, but isolated.

image

What we need to do is ensure the feature branches are up to date with any activity that may have occurred during their development phase and then merge the changes back to main, validate and ship v3.

Merge all changes and ship a new major release

Merge featureMOD

  • Forward-Integration (FI) merge
    • Right-click on the main branch in Source Control Explorer, select Branching and Merging, and Merge.
    • Verify that source is $/BranchingScenarios/main and target is $/BranchingScenario/featureMOD.
    • Select Next, set Version type to All changes up to a specific and select Next.
    • Select Label, find the V2 label as shown and select Next.
      image
    • Read the merge operation summary and select Finish to perform a forward integration (FI) merge as shown below.
    • As there have been no changes in main, you will see the “no changes to merge” dialog.
      image
  • Reverse-Integraton (RI) merge
    • Right-click on the featureMOD branch in Source Control Explorer, select Branching and Merging, and Merge.
    • Verify that source is $/BranchingScenarios/featureMOD and target is $/BranchingScenario/main.
      image
    • Select Next, set Version type to Latest Version and select Next.
    • Read the merge operation summary and select Finish to perform a reverse integration (RI) merge as shown below.
    • Check in your changes to the main branch.
  • We performed the following FI and RI merges.
    image

Merge featurePOWER

  • Same as previous, but focused on other feature.
  • Forward-Integration (FI) merge to get the latest changes from main, resolve possible conflicts in the feature branch, and stabilize before merging back into main.
    • Right-click on the main branch in Source Control Explorer, select Branching and Merging, and Merge.
    • Verify that source is $/BranchingScenarios/main and target is $/BranchingScenario/featurePOWER.
    • Select Next, set Version type to All changes up to a specific and select Next.
    • Select Label, find the V2 label as shown and select Next.
      image
    • Read the merge operation summary and select Finish to perform a forward integration (FI) merge as shown below.
    • Note that we are merging the featureMOD feature into the featurePOWER branch at this point.
  • · Reverse-Integration (RI) merge
    • Right-click on the featurePOWER branch in Source Control Explorer, select Branching and Merging, and Merge.
    • Verify that source is $/BranchingScenarios/featurePOWER and target is $/BranchingScenario/main.
      image
    • Select Next, set Version type to Latest Version and select Next.
    • Read the merge operation summary and select Finish to perform a reverse integration (RI) merge as shown below.
  • We performed the following.
      image
  • If you plan to continue using the featureMOD branch , we recommend a forward integration (FI) merge from main to featureMOD, to merge the featurePOWER changes.

Verify and release.

  • Open the solution in the main branch and by setting the command line arguments as before, verify the following calculations:
    • Test 4 2 +
    • Test 4 2
    • Test 4 2 *
    • Test 4 2 /
    • Test 5 2 %
    • Test 4 2 ^
  • Label the latest changes in the main branch as V3.
    image

Optionally (not recommended) delete the Feature Branches

None of us is crazy about this optional task as most teams want the audit trail and traceability. Deleting or worse, destroying, everything kind of defeats the purpose of VC.

We delete the feature branch, folder and associated artefacts, keeping history in version control for auditing and safety reasons. If you are happy to permanently delete the artefacts, you can use the tf utility to permanently destroy. Caution, the destroy operation cannot be reversed.

tf destroy destroys, or permanently deletes, version-controlled files from Team Foundation version control.

Delete featureMOD

  • Right click on featureMOD branch in Source Control Explorer and select Delete.
    image
  • Right click on BranchingScenarios folder and select Check in Pending Changes.
  • Select Check In, which will delete the featureMOD branch.

Delete featurePOWER

  • Right click on featurePOWER branch in Source Control Explorer and select Delete.
  • Right click on BranchingScenarios folder and select Check in Pending Changes.
  • Select Check In, which will delete the featurePOWER branch.

Review

We explored the feature isolation strategy, how to implement and why to use. We implemented two clearly defined and isolated features and have shipped v3.

image

In this exercise we performed:

  • 2 branches
  • 4 merges, i.e. two FI’2 and two RI’s
  • 1 label

Next up: Version Control Walkthrough Part 4 - Release Isolation … audit alarm


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 (6)

  1. Juan Quijano says:

    Very usefull post serie.

    Very thank you!!

  2. Pavan says:

    This is very helpful. Thanks

  3. Doktoro Kiu says:

    Thanks a lot for this series; it has given me the confidence to start branching out on my own 😉
    The mixing of folders and branches in TFS was a little confusing for me, but now it all makes sense (and is a useful concept, too). As a side note, your exponentiation routine has a problem. The line inside the for loop should be “valueResult *= valueOne”, not “valueResult *= valueResult”. I’m not sure if this was intended or not (as an incomplete test coverage example), but I’d hate for anyone to be confused by this. The ^ 2 case will miss this bug.

    1. Thank you for your feedback. The logic error was indeed intentional as the code comes from a Hands-on Lab that demonstrates value of unit testing and using more than one data set. I have corrected the code, to avoid confusion within the context of this post.

      Have you seen the latest versions of the branching guidance and related articles in https://aka.ms/techarticles? We are in the process of merging a lot of guidance we had on CodePlex and blogs, with the main product documentation to improve discover-ability and consistency.

      1. Henry says:

        Hello Willy-Peter,

        I’d like to get my team in sync with the latest guidance. But, the link you provided may not be correct. Can you please validate it?

        Many thanks,
        Henry

        1. Henry, which of the URLs is incorrect? Please review The new Branching Guidance for Team Foundation Server, Team Services, and others (https://blogs.msdn.microsoft.com/visualstudioalmrangers/2016/07/18/the-new-branching-guidance-for-team-foundation-server-team-services-and-others/).

Skip to main content