Getting Started with Virtual Streams
This is the last of a three-part series on virtual streams.
In this post I'll try to answer a few nuts-and-bolts questions about virtual streams. If you have any questions that I didn't address here, let me know and I'll start a FAQ in the forums.
Creating virtual streams
Creating a virtual stream is really easy, since there's no actual branching involved. You just create a new stream, set the Type to virtual, choose the Parent stream, and adjust the other options (particularly the paths) accordingly.
If you are using P4V's Stream Graph, the Parent field will be filled in automatically if you right-click on the parent stream and select Create New Stream from.
What happens if you make a child stream from a virtual stream?
That's fine and expected. Let's say you have a child stream that is less stable than a virtual stream. When you merge changes to your child stream from the virtual stream, you're actually picking them up from the virtual stream's parent. When you copy stable work up to the virtual stream, it actually flows through to the virtual stream's parent.
Consider this stream graph:
If the merge arrow to the lisa stream is lit up, I can run p4 merge normally, or run the equivalent action through P4V. Merging down to the lisa stream actually pulls in changes from lightning, the non-virtual parent of v_bruno_team.
> p4 client -s -S //weather/lisa
> p4 update
> p4 merge -r -S //weather/lisa
> p4 resolve -at
c:\P4DemoWorkspaces\bruno_weather\src\rules.c - resolving branch from //weather/lightning/src/rules.c#1
> p4 submit
Similarly, copying stable work up from the lisa stream into a workspace on the virtual stream actually sends it to lightning.
> p4 client -s -S //weather/v_bruno_team
> p4 update
> p4 copy -S //weather/lisa
//weather/lightning/src/glob.c#1 - sync/integrate from //weather/lisa/src/glob.c#2
> p4 submit
If your child stream is more stable then a virtual stream, you get the same behavior, except that the flow is reversed. So you can merge changes from your child stream to the virtual stream, which would flow through to the virtual stream's parent. If necessary, you could copy stable work to your child stream.
For the most part using a virtual stream should be very similar to using a 'normal' stream in daily work. If you are familiar with working in Perforce streams, working with a virtual stream won't pose any challenges. You just need to remember that your changes are actually being submitted to the virtual stream's parent.
Why can't I merge from a virtual stream's parent to the virtual stream?
Remember that a virtual stream contains no files; it's really acting as a view into the parent stream. So there's no concept of merging from a virtual stream's parent to the virtual stream: they're both looking at the same set of actual files!
We also describe this concept by saying that a virtual stream has no flow with respect to its parent. Another way of expressing the idea is saying that a virtual stream has automatic flow with respect to its parent: anything in the parent stream is automatically reflected in the virtual stream, subject to its view, without any merges or copies.
Can I chain several virtual streams?
Yes, and if you're working on a really complex project with tens of modules, you'll probably want to. There are no limitations on how deep the stream hierarchy can get, and you can mix and match virtual and 'normal' streams as much as you want.