1

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
user4776
  • 11
  • 2
  • This may be a silly question, but why not just do the upgrade in the Testing branch directly? If you're able to just move the upgraded assets to the testing branch and expect them to work, I'd assume the two branches are similar enough that you could just do the upgrade there in the first place. – Samwise Oct 29 '20 at 01:02

1 Answers1

2

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.
Samwise
  • 68,105
  • 3
  • 30
  • 44
  • Thanks. I could go through p4, but seeing as this is something that we'll likely have to do a few more times in the future, do you know what this looks like in p4v? – user4776 Oct 29 '20 at 01:18
  • I recommend doing it in p4 yourself first, and then you can reverse-engineer the more complex process of doing it in P4V if you're locked into supporting that for other people -- I don't know offhand how to do it in P4V, but in most cases it's just a matter of spending enough time poking around to find the right combination of dialogs and checkboxes that correspond to each p4 command. Worst case scenario you can build it as a "custom tool", which is usually what I've ended up doing when I need to make slightly atypical things easier in P4Win/P4V. – Samwise Oct 29 '20 at 01:50
  • Of the above options, the "do it in its own branch" is probably the easiest to map to P4V, FWIW. – Samwise Oct 29 '20 at 01:52