Search code examples
version-controlbranchperforcep4vperforce-stream

How do Perforce streams handle subpaths with different access than parent path?


For configuration of streams in Perforce, there exist five access types (according to documentation, in order more-to-less-inclusive): share, isolate, import/import+, exclude. They are placed in the configuration line-by-line, like so:

share folder1/...
isolate folder2/...

Is it possible to override the access to a subfolder? Like so:

share folder/...
isolate folder/subfolder1/...

In the way that, folder/subfolder1/... will be isolate-d, but folder/subfolder2/... and all others will be share-d? It seems like a lot of manual work to include all separate subfolders otherwise, especially if they are added as development progresses.

If this works, what are the rules? Do later lines override earlier lines?

Or do more restrictive access lines override less restrictive ones (i.e. can share parent folder, isolate child folder, but not other way around)? E.g. is something like

exclude folder/...
share folder/subfolder1/...

also possible?


Solution

  • Let's try it out. If I change my stream Paths to:

    Paths:
            share folder/...
            isolate folder/subfolder1/...
    

    here's what I get when I try to merge a path that's inside the isolated folder and outside it:

    C:\Perforce\test>p4 merge -n folder/subfolder1/...
    folder/subfolder1/... - no target file(s) in branch view.
    
    C:\Perforce\test>p4 merge -n folder/subfolder2/...
    No such file(s).
    

    which tells me that, indeed, subfolder1 is isolated correctly. The "no target files in branch view" error tells me that the path is excluded from the branch view (which is the function of isolate), whereas "no such file(s)" lets me know that the only reason there's nothing to merge is that I didn't bother to actually add any files there.

    Let's try the other example and see how that works. After changing my Paths to:

    Paths:
            exclude folder/...
            share folder/subfolder1/...
    

    I can do a similar experiment with p4 sync:

    C:\Perforce\test>p4 sync -n folder/subfolder1/...
    folder/subfolder1/... - no such file(s).
    
    C:\Perforce\test>p4 sync -n folder/subfolder2/...
    folder/subfolder2/... - file(s) not in client view.
    

    and that also works as I'd expect (basically the same way classic client views work) -- the later and more specific line overrides the earlier and more general line, so subfolder1 is shared while subfolder2 is excluded.