Search code examples
perforcep4vperforce-integrate

Copy files from changelist of a branch to changelist of another branch


Let's assume two branches in Depot have similar file structure, and their contents may be different:

Branch A
+---image
|   \---img0
|   \---img1
+---dev
|   \---foo
+---other
|   \---bar

Branch B
+---image
|   \---img0
|   \---img1
+---dev
|   \---foo

In my changlist#100, I shelved all modified files in branch A (img0 and foo), but I can not submit them just yet due to our team policies. I wanted to copy those files to branch B (you are guaranteed to find those files already in branch B).

So I created changlist#101, and successfully merge/integrate those files to changlist#101 that contains files in branch B. However, I don't know how to resolve them so the content of img0 and foo are identical in these two CLs without manually doing all of them (there might be hundreds of files).

I checked answers like Merging changes from one branch to another, but they are not what I am looking for.

Thanks in advance.


Solution

    1. Either submit or revert your change 101 -- the next steps will be simpler if the files aren't already open in your workspace.
    2. Use p4 branch to create a branch view (if one doesn't already exist):
    Branch: branchAtoB
    View:
        //depot/branchA/... //depot/branchB/...
    
    1. Unshelve change 100 via the branch view, scheduling a resolve from the branch A shelf into branch B:
    p4 unshelve -s 100 -b branchAtoB
    
    1. Normally, you would use p4 resolve -am as the next step, but if you want to unshelve the exact revisions from the shelf, rather than merging the changes in the shelf with any existing changes in branch B, use p4 resolve -at to force a copy (note this may overwrite changes in branch B and/or copy in earlier changes from branch A).