Condividi tramite


Version Control Walkthrough (Branching Strategies) Part 2 - Development Isolation … welcome branching

Continued from Version Control Walkthrough Part 1 - MAIN Only and Simplicity Rules we explore development isolation.

Goal

Explore the Development Isolation strategy which introduces one or more development branches from main, enabling concurrent development of the next release, experimentation or bug fixes in isolated development branches. Context

Your team needs to maintain a stable main branch for the major release supported in production and invest in concurrent development to add a multiplication feature to the calculator solution. image

Create the Development Branch to isolate new development

Create dev branch

  • Right-click on main in the Source Control Explorer, select Branching and Merging, Branch.
  • Define the Target Branch Name as $/BranchingScenarios/dev, as shown, and click Branch.
    image
  • You could use any name for the dev branch, i.e. dev, research or development, but strive for consistency to avoid the potential for confusion and error.
  • Right-click on BranchingScenarios folder in the Source Control Explorer and select Get Latest Version.
    image
NOTE In the real-world you may consider creating a second workspace for the dev branch to isolate it from main.
  • Right-click on dev branch in Source Control Explorer, select Branching and Merging and View Hierarchy to view a visualization of the main and dev branches.
    image
  • Time permitting, view some of the other diagrams.

Extend the feature

  • Open the 6_MEF.sln solution in the dev branch.
    image
  • Add class CalculationExtension_Mul and the division 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 multiplication.
    image

Test new 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 multiplication feature works as shown.
    image
  • Check in your changes to the dev branch.
  • Add a label v2.DEV to this latest feature check-in as a bookmark to indicate that feature testing is complete.
    image
  • We are feature complete and ready to integrate dev changes to the main branch.

Fix a bug in Main as a hotfix

Investigate the bug

  • The users have reported that the subtraction feature in our v1.1 release is broken.
  • Switch context to the main branch, which contains the production release.
  • Open the 6_MEF.sln solution in the main branch.
    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 -
  • Build and Run (F5) the solution.
  • Notice that the user is correct, the subtraction seems to be adding the values.
    image

Fix the bug

  • Edit the …\main\CalculationExtension_Sub.cs file and notice the gremlin.
    image
  • Change the + to a - to correct the bug and optionally remove the comment.
    image

Validate and test

  • Build and Run (F5) the solution.
  • Verify that your subtraction feature works as shown.
    image

Check-in, label and ship v1.1 hotfix

  • Check-in the changes in the main branch.
  • Label the latest changes in the main branch as v1.1 hotfix.
    image

Context – Intermission

As shown below we have a stable v1.1 Hotfix release in main and a stable v2.DEV release in the dev branch at this point … image

What we need to do is share the hotfix with the dev team and then merge all the changes back to our main branch so that we can offer the latest and greatest release, which include + - * / features with our customers.

Merge all changes and ship a new major release

Merge hotfix to dev branch

  • Right-click on the main branch in Source Control Explorer, select Branching and Merging, Merge.
    image
  • Verify that source is $/BranchingScenarios/main and target is $/BranchingScenario/dev.
    image
  • Select Next, set Version type to Latest Version and select Next.
  • Read the merge operation summary and select Finish to perform a forward integration (FI) merge as shown below:
    image
  • You should experience no merge conflicts as we have not made any conflicting changes.
  • Check in your changes to the dev branch, comprised of CalculationExtension_Sub.
  • For safety, re-test the division feature and the subtraction feature.

Merge dev branch to main branch

  • Right-click on the dev branch in Source Control Explorer, select Branching and Merging, and Merge.
    image
  • Verify that source is $/BranchingScenarios/dev and target is $/BranchingScenario/main.
  • 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.
    image
  • Right-click on the main branch in Source Control Explorer and select Check In Pending Changes, which includes 6_MEF,csproj project file (merge,edit) and CalculationExtension_Mul,cs (merge,branch) .

Validate and test

  • 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 /

Label and ship v2.0

  • Label the latest changes in the main branch as V2.
    image

Review

We explored the development isolation strategy, how to implement and why to use. We explored how to work on a hotfix and development feature concurrently, merging the innovations back into the stable main branch at the end of the exercise. image

In this exercise we performed:

  • 1 branch
  • 2 merges, one FI and one RI
  • 3 labels

Next up: Version Control Walkthrough Part 3 - Feature Isolation … a special!


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

  • Anonymous
    September 17, 2015
    I think most of the teams i work with follow this strategy, great article.

  • Anonymous
    September 23, 2015
    I think there's a typo under "Fix a bug in Main as a hotfix" - shouldn't it say "Open the 6_MEF.sln solution in the main branch"?

  • Anonymous
    September 24, 2015
    The comment has been removed