perforceperforce-stream

How to properly manage file versions when using branch mapping merge in Perforce?


In continuation of this problem How do I extend parent stream mapping in Perforce? I now have another problem, my file versions get share'd from mainline stream and they have newer versions, while the OtherFeatureStream has only a subset of these files and pull them from mainline from time to time

The goal is to make a feature in MyFeatureStream that should be built on top of other feature from OtherFeatureStream but my feature wants a wider file mapping

Streams layout

           Mainline
           ^      ^
           |      |
    --------       --------
   |                      |
   V                      V
MyFeatureStream << OtherFeatureStream
          (branch mapping)

Project structure:

- Root
    - src
        - Folder1
        - Folder2

OtherFeatureStream is defined as that

import ... //mainline/...@12345
share //mainline/src/Folder1/...

MyFeatureStream is defined as:

import ... //mainline/...@12345
share //mainline/src/...

+ I do branch mapping merge when new code comes into OtherFeatureBranch

The problem is that in MyFeatureStream code for Folder2 is newer than in OtherFeatureStream and hence the code doesn't run. My first thought was that I can somehow fix the version of share like I did in import but it doesn't work.

Here is how sharing diagram looks like
enter image description here
Orange region is my sharing set and the other stream is a complete subset of my sharing set

Outer orange subset is code that import'ed in the other stream and fixed to a changelist 12345, Red circle is files that I pull from the other stream using branch mapping

Is there a way to guarantee that my share'd Orange outer subset is editable and always has the base of 12345-changelist version of files from mainline but I could submit changes to these file into my stream MyFeatureStream?


Solution

  • You'll need to reconcile the code in your feature stream(s) with the latest changes in the mainline at some point, so my inclination would be to make the changes in MyFeatureStream as needed to maintain compatibility with the newer changes that you'll pulling in via the wider share path. My expectation is that it'll be easier to do this as the changes are pulled in than to try to deal with the accumulated incompatibilities right as you're ready to copy up to the mainline.

    However -- if you want to isolate that folder from changes in the mainline, you can use an isolate path. Do it like this:

    1. To start with, set up MyFeatureStream exactly as you have, with all src paths shared:
    Stream: //depot/MyFeatureStream
    
    Parent: //depot/mainline
    
    Paths:
        import ... //depot/mainline/...@12345
        share src/...
    
    1. Make sure that you only branch Folder2 at that change:
    p4 copy -F src/Folder2/...@12345
    p4 submit -d "branch Folder2 @12345"
    

    Be careful -- if you have already merged newer changes into this stream and you do a p4 copy from an older change, it will roll the newer changes back! I'm assuming here that you're setting up a new stream.

    1. Isolate the changes in that folder from the mainline:
    Stream: //depot/MyFeatureStream
    
    Parent: //depot/mainline
    
    Paths:
        import ... //depot/mainline/...@12345
        share src/...
        isolate src/Folder2/...
    

    From this point on, Folder2 will be excluded from future merges from mainline, so it will not receive changes past @12345. Now you can branch the rest of the stream:

    p4 copy -F
    

    and you should see all the rest of the src files opened for branch from the latest revisions, while Folder2 remains at the older revisions.

    Again: you will just need to undo all this all at once when you propagate your feature branch changes back to the mainline, so my advice would be to not isolate this folder and instead deal with the breaking changes in your feature stream as they arrive.