user4776
user4776

Reputation: 11

How to push modified code in a perforce changelist to another branch?

Basically, I've got main and UnityVersion_Testing branches. The team is all using p4v, but it's an uphill battle. Our project is on an older version of Unity, and I'd like to run the automatic upgrade by running the old project in the new engine and then push to a branch we've got in Perforce specifically for such an occasion.

What I thought I was supposed to do was run the upgrade, those files that are modified are now in a new pending changelist, I shelve those files, switch streams to UnityVersion_Testing, and then I thought I'd be able to unshelve those files there. No luck. The shelved files appear to belong to the other workspace. I then tried to unshelve the files. I can't, because they're still checked out, and I can't seem to get them into a state where they'll accept being unshelved.

How do I pull latest from main, upgrade the assets in place in the new version of Unity, and then push to our existing UnityVersion_Testing branch so that I'm in a good place to merge those changes back into main when it's passed regression testing?

Upvotes: 1

Views: 370

Answers (1)

Samwise
Samwise

Reputation: 71424

You can use shelves to move pending work from one stream to another, but it's easier to use p4 switch -r.

C:\Perforce\test>p4 edit foo
//stream/main/foo#4 - opened for edit

C:\Perforce\test>echo upgrade >> foo

C:\Perforce\test>p4 switch -r test

C:\Perforce\test>p4 opened
//stream/test/foo#1 - edit default change (text)

C:\Perforce\test>p4 diff
==== //stream/test/foo#1 - c:\Perforce\test\foo ====
3a4
> upgrade

If you use shelves, it's more steps -- you need to shelve, revert, switch streams, and then unshelve (using the "-S" flag to specify that you want to map the shelf through the stream view):

C:\Perforce\test>p4 edit foo
//stream/main/foo#4 - opened for edit

C:\Perforce\test>echo upgrade >> foo

C:\Perforce\test>p4 shelve
Change 209 created with 1 open file(s).
Shelving files for change 209.
edit //stream/main/foo#4
Change 209 files shelved.

C:\Perforce\test>p4 switch test
Can't switch while files are open in a numbered changelist; 'p4 revert' files or 'p4 reopen' files into the default changelist

C:\Perforce\test>p4 revert ...
//stream/main/foo#4 - was edit, reverted

C:\Perforce\test>p4 switch test

C:\Perforce\test>p4 unshelve -S //stream/test -s 209
... //stream/test/foo - must resolve //stream/main/foo@=209 before submitting

C:\Perforce\test>p4 resolve -am
c:\Perforce\test\foo - merging //stream/main/foo@=209
Diff chunks: 0 yours + 1 theirs + 0 both + 0 conflicting
//Samwise-dvcs-1509687817/foo - copy from //stream/main/foo

C:\Perforce\test>p4 diff
==== //stream/test/foo#1 - c:\Perforce\test\foo ====
3a4
> upgrade

Another option would be to use a staging branch for the upgrade, submit the upgrade there, and then merge it to the test branch rather than moving it around as a pending changelist:

C:\Perforce\test>p4 switch
main

C:\Perforce\test>p4 switch -c upgrade
upgrade

C:\Perforce\test>p4 edit foo
//stream/upgrade/foo#1 - opened for edit

C:\Perforce\test>echo upgrade >> foo

C:\Perforce\test>p4 submit -d "Try out the upgrade on the upgrade branch"
Submitting change 207.
Locking 1 files ...
edit //stream/upgrade/foo#2
Change 207 submitted.

C:\Perforce\test>p4 switch test

C:\Perforce\test>p4 merge --from upgrade @=207
//stream/test/foo#1 - integrate from //stream/upgrade/foo#2
... must resolve content from //stream/upgrade/foo#2

C:\Perforce\test>p4 resolve -am
c:\Perforce\test\foo - merging //stream/upgrade/foo#2
Diff chunks: 0 yours + 1 theirs + 0 both + 0 conflicting
//Samwise-dvcs-1509687817/foo - copy from //stream/upgrade/foo

C:\Perforce\test>p4 diff
==== //stream/test/foo#1 - c:\Perforce\test\foo ====
3a4
> upgrade

C:\Perforce\test>p4 submit -d "Merge the upgrade to the test branch"
Submitting change 208.
Locking 4 files ...
integrate //stream/test/foo#2
Change 208 submitted.

Upvotes: 2

Related Questions