Search code examples
lockingperforceunshelveshelving

Unshelve a file which is in exclusive check out in Perforce/P4


Perforce noob here - I have a file on a shelf which I want to unshelve to run a few things, however the file is exclusively checked out on another machine. Ideally what I want to do is unshelve the file locally, do a few things, then toss out my local changes.

I considered using p4 print and p4 copy but they don't seem to work as required - e.g. copy seems to copy files between depot paths.

How can I unshelve and ignore the lock? Alternatively, how can I download the file from the shelve to overwrite it locally?


Solution

  • Two options:

    1. Use p4 print FILE@=SHELF to get the content of the file. This is very straightforward for one file but will be annoying for multiple files.

    2. Create a new branch/stream and unshelve it there; the exclusive lock isn't global across branches so you can do whatever you want in your own branch.

    With streams option 2 looks like:

    p4 switch -c my-new-stream
    p4 unshelve -S my-new-stream -s SHELF
    

    With manual branch specs it looks more like (assuming your client maps everything, if not there's an extra step of adding the new branch to your client mapping):

    p4 branch my-new-branch
    (fill in a view mapping the current branch to your new branch)
    p4 copy -b my-new-branch
    p4 submit
    p4 unshelve -b my-new-branch -s SHELF