'Are nested workspace mappings possible with Perforce?

Can I have a workspace mapping where some depots or parts of depots get mapped as subdirectories of another depot mapping, like in this example workspace definition:

//Depot_Base/...    //WorkspaceWithNestedMapping/...
//Depot_Sub1/...    //WorkspaceWithNestedMapping/Sub1/...
//Depot_Sub2/D2/... //WorkspaceWithNestedMapping/D2/...

without p4 becoming confused where some added file below D2 should get stored on the server? (Depot_Base vs Depot_Sub2, I want it to become part of Depot_Sub2)



Solution 1:[1]

Yes, this is completely possible and a very normal way of using workspace mappings. When different lines conflict, later lines override earlier ones.

One way to think about it is that for a given file path, the mapping is checked from the bottom up, and the first match is the one that is used. So if you do:

p4 add //WorkspaceWithNestedMapping/D2/foo

the matching line is the one at the bottom of the mapping, and the file is added as:

//Depot/Sub2/D2/foo

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Samwise