Branching is the process of creating a new codeline from an existing codeline. Branching is easy and fast with streams.

As an Intermediate User, the primary motivation for branching would be to create development branches for bug fixes, product patches, and private research and development efforts.

To create a new branch in streams, you create a new stream. In most cases, new streams are children of existing streams and, by default, inherit the parent's configuration settings, the parent's client view definition, and the scope of files, or stream view, defined for the parent stream. The flow of change between the new child stream and its parent is also pre-configured based on the stream's type designation.

The notable exception to this rule is the mainline stream that has no parent and therefore does not inherit any configuration information.

Creating and populating a new stream, by default, are two separate operations. You can configure Perforce, however, to immediately branch files from a parent stream on stream creation.

You can configure the stream settings directly in the stream spec using the command line client or through the “create new stream” or “edit stream” dialogs in P4V.

When you branch using streams, there are a few points to remember:

By default, child streams inherit the stream view of their parent.

You can modify the stream settings for a child stream to further refine the child stream's view.

Child streams can’t branch more than their parent streams are willing to share (paths defined with the share type).

The stream view defines both the branch view, which is used to integrate files between parent and child streams, and the client view for workspaces connecting to the stream.

Although streams relies on the same underlying technology for propagating changes across codelines as Classic Perforce, such as the copy and merge commands and the resolve dialog, the Stream Graph provides visual clues that tell a user about pending changes and a set of stream-specific dialogs and hints to help users make the right decisions and do the right thing when integrating changes.

For example, notice in the diagram that the connectors between stream main and stream dev show that there are changes pending between the two streams. In this case, the stream framework regulates the flow of change between the two streams by suggesting that the files be merged from stream main to stream dev, as illustrated by the green connector, before they are copied from stream dev to stream main, as illustrated by the orange connector.

To merge the changes from stream main to stream dev, you can double click on the stream and open a special stream dialog that provides a link to execute the proper integration behavior, in this case a merge.

You resolve conflicts that might exist during a merge using the resolve dialog, just as you would in Classic Perforce.

Notice that once you merge the pending changes from stream main to stream dev, the associated connector changes from green to gray, and the connector for the copy between stream dev and stream main turns to green, signifying that you can now perform the copy operation.


Course - Using Streams to Simplify Codeline Management