January 22, 2016
Pro Tip: Use Ignored Paths to Slim Down Your Workspaces
Email sign up
One of the nice things about working with Perforce Helix streams is that the system handles creating and updating workspace views for you. A lot of the power of Helix comes from the flexibility of workspace views, but manipulating them is a bit of a dark art. A popular reason to learn this dark art is to exclude large files you don’t need; why sync a multi-gigabyte file you’ll never look at? Thankfully Ignored paths and virtual streams can help us get that level of control without learning the intricacies of workspace views.
If you haven’t worked with virtual streams before you’re missing out; they make it very easy for a team to have predefined workspaces for different purposes. All syncs and submits use the parent stream’s files, but you can reduce the set of files that are synced. You can also swap in alternate imported libraries just like you can from a normal child stream. On some projects I’ve worked on, we’ve had separate virtual streams for each platform we support so that developers grab only the tools and libraries they need for the platform they are working on.
Here at Perforce we believe in versioning everything, including the virtual machine images that we use for testing. When you need them it’s extremely handy, but when I’m doing doc work I don’t need all 16GB of the latest images. Let’s build a virtual stream to pare down my workspace.
First off I’ll create my child stream:
$ p4 stream -t virtual -P //qt/p4v/main //qt/p4v/doc_work
-t tells Helix I am making a virtual stream. -P tells Helix what that parent will be. The stream’s name in this case is doc_work.
Running the command above will open up a form to edit my new stream. To this form I will add an Ignored section and the file extensions I want to block:
After saving the form, I can run p4 switch doc_work and I’m ready to rock! The VM images are excluded, and everything else I need is there. I don’t have to worry about which paths the VM files live in because I’m excluding them by extension.
This will only work for you if you want to block a filetype across an entire stream, but generally that is the case. If the files you don’t want live in a specific part of the tree you can use an exclude line in the stream paths to remove them.
Streams were designed to make life easier, but there is a lot of functionality packed in there. If you’re having issues with streams or have questions about how to use them more efficiently reach out to me on Twitter @p4mataway or hit up Tech Support via email at firstname.lastname@example.org