null
February 7, 2020

Perforce Branching 101

Branching
Version Control

Branching and merging are standard operations for developers and DevOps teams. This blog walks you through Perforce branching and merging in Helix Core version control.

First, What Is a Branch?

A branch is a copy of a codeline. Branching code helps software development teams work in parallel.  Branching keeps the “main” codeline –– referred to in Perforce as the mainline –– stable. And it enables developers to iterate independently from the mainline.

Developers create branches to experiment in isolation without jeopardizing overall product stability. As they are working, it is a best practice to keep branches up to date with changes in related codelines.

What Is Merging?

Branching creates a relationship between a branch and the codeline the branch originated from. As the developer is working on a branch, a best practice is to keep the branch updated with changes. This is done by merging changes from the related codeline into the branch as that codeline changes. Merging new changes into a branch helps decrease the likelihood and complexity of a merge conflict. Your motto should be “merge early, merge often.”

Managing Relationships Between Branches

But if you have thousands of developers, merging gets complicated, fast. This is because most version control systems (VCS) –– like SVN and ClearCase –– do not systematically keep track of the relationships between branches. This requires development teams to track these relationships manually.

Tracking is often done using a flowchart stored on a team wiki or on a white board with a “do not erase” sign plastered next to it. It also often requires complex scripting on top of the VCS. This can be costly to set up and usually requires a team of administrators to maintain.

If (and when) a branch is merged back in the wrong place, or merge conflicts are not properly resolved, builds can break. This causes developers to spend time troubleshooting issues, which decreases velocity and can cause release delays.

What Is Perforce Branching? Perforce Streams

All version control systems have branching. But in Helix Core, we have Perforce Streams. Streams offers built-in support for complex branching and merging operations. Teams can manage thousands of codelines and visually track relationships between codelines to allow for stress-free merging.

[VIDEO] See Streams In Action >>

What Makes Perforce Branching Different

There are several advantages to using Streams. You can:

  • Create and visually show the dependencies between branches.
  • Systematically enforce best practices (i.e., merge down, copy up) around branching and merging.
  • Switch between codelines fast.
  • Set up developer workspaces automatically upon branch creation.

Why You Need Perforce Streams

Streams encourages the merge early, merge often principle by visually showing when a merge should happen. This avoids large, costly merge conflicts at the end of projects that can often break builds and delay releases. The result is increased velocity and more time spent on new feature development.

Perforce Branching: Streams 101

Streams makes your developers –– and admins ­­–– lives easier. Learn how.

You Can Develop Your Way

Streams adapts to how your team works. You can set it up to match your branching strategy –– e.g., by team, feature, component, or stage of development. It creates a flexible system that supports how you build your projects. You can use Streams if you use a monolith, microservices, or component based development architecture.

This is because it’s easy to configure Streams to work on components and modules. And Streams automatically keeps track of your dependencies. This allows you to more easily test all the code together, ensuring that you ship high-quality code on time.

You Can Visualize Changes

When changes are available in a related codeline, developers can quickly see what is happening in the Stream Graph. Using the colored arrows, they know what streams are dependent on their changes. And they can tell when they need to merge down new changes from other team members.

Get a Tiny Tutorial of Perforce Streams >>

You Can Easily Investigate File History

Helix Core offers features that allow you to easily see a file’s branching history. Using the Revision Graph, you can see the file integration history. This history includes when a file is:

  • Added
  • Branched
  • Edited
  • Merged
  • Copied
  • Deleted

Using this feature allows you to quickly and easily view the branching structure to see how the file has evolved. That means if there is a merge conflict, you can go back in and see what happened, and when.

You can also use the Time-lapse View to view the branch history of a given file. This gives you an alternative view of how a file has evolved over time. It helps answer questions like, “when was this line of code introduced and by whom?”

You Can Use Your Favorite Tools

Streams functionality is available in Helix Visual Client (P4V), as well as directly from the Helix Command-Line Client (P4). These tools are both supported on Linux, Mac, and Windows.

Streams also works with popular IDEs ––like Visual Studio, Eclipse, and more –– integration tools, and APIs. Now your admins can spend less time onboarding developers and monitoring branch/merge scripts, and start automating more.

Perforce Branching With Streams

Perforce Streams is just one of the many features Helix Core provides to help accelerate development.

Helix Core can handle everything –– thousands of users, millions of daily transactions, and terabytes of data. And as your teams and projects grow, Helix Core can deliver files and feedback around the globe without a WAN wait.

Admins less time setting up and maintaining branching workflows. Developers can get the files they need, fast.

Plus, Helix Core is free for 5 users.

TRY TODAY