perforce

P4: How can I submit a shelf?


I have a set of 4 files, 2 were revised and 2 were changed. I have 4 changelists. Only one of those changelists correctly represents what I need to change and has the changes. The other 3 have subsets. All 4 changelists show in the P4V "Pending" tab.

I tried

p4 submit -c nnn

where nnn is the changelist with all the changes, I got

Change nnn has shelved files -- cannot submit

I did research and found out about -e and tried

p4 submit -e nnn

I got

No files to submit
Cannot submit - Files are opened at client path_to_client at change nnn

This changelist has been through SWARM so it has fulfilled all the other things I wanted it to fulfill.

I tried right-clicking the changelist in the list of pending changelists and it didn't even let me submit.


Solution

  • A pending changelist can potentially have both opened files and shelved files. Opened files live in the client workspace; shelved files live on the server.

    When you submit, you're taking one of those sets of files associated with the pending changelist and turning them into a submitted changelist. If you do p4 submit [-c] you're submitting the opened files; if you do p4 submit -e you're submitting the shelved files.

    If a pending changelist has both opened and shelved files, you can't submit it, because whichever set of files you don't submit will be lost. You must explicitly discard the unwanted changes. In your case you want to submit the shelved files and presumably don't care about the opened files, so you can do:

    p4 revert -c nnn //...
    p4 submit -e nnn
    

    If you want to keep your opened files instead of reverting them, put them in a different changelist (e.g. the default changelist):

    p4 reopen -c default //...
    p4 submit -e nnn
    

    If you wanted to discard the shelf and instead submit the opened files from your workspace, you'd do:

    p4 shelve -d -c nnn
    p4 submit -c nnn
    

    If prior to deciding whether to revert or reopen you want to check whether your locally opened files differ from the shelf, do:

    p4 diff @=nnn
    

    Note that if this shows that all files are identical, there is no difference between submitting the shelf and submitting the opened files; this would be the expected state if you haven't made any local modifications since shelving the files. (Perforce does not consider the file diffs or lack thereof when giving an error like "has shelved files, cannot submit".)