Search code examples
phpstormwebstormperforce

Perforce and PhpStorm/WebStorm: shelved files from default changelist disappear


I am just learning how to use Perforce for version control so my understanding of its processes is weak. PhpStorm 2017 is my IDE.

I'd like as much as possible to use the IDE for version control operations, so I linked up the IDE to the Perforce client successfully (instructions). I created some files and in P4V, they appeared in the Default pending changelist. Once I finished, within PhpStorm I selected "Menu bar >> VCS >> Shelve changes..." expecting to see the files moved to a shelf within the changelist in Perforce.

Instead, the files have disappeared as best I can tell. They are gone from the OS folder structure, and don't show up in Perforce either in the Default changelist or any shelf.

I need help figuring out:

  • what happened to my files?
  • how do I get them back?
  • can PhpStorm/WebStorm be used to work with Perforce shelving/unshelving? If so, how to do it properly?

Solution

  • There were a couple of concepts I needed to understand first:

    PhpStorm offers its own shelve/unshelve functionality, independent of any Version Control System

    My files could not be found because "Main menu >> VCS >> Shelve changes..." put them in the IDE's shelf, not Perforce's. The IDE's shelf is inside <project-root>/.idea/shelf

    What gets shelved is a set of changes since the last commit, not the file itself

    This led to a fundamental misunderstanding on my part. I thought my files were missing because I couldn't see them in the OS folders, but what was missing were changes made to those files. It's because the files were new -- and thus the changes were comprised of the whole files -- that it appeared as though the files themselves were missing.

    What actually happened when I shelved: the files were rolled back to their previously committed state (in my case nonexistent), and the changes were saved on the shelf

    All shelving/unshelving is accessible from the Version Control tool window

    Pressing Alt + 9 brings up this tool window. When items have been shelved, there is a Shelf tab. From there, I was able to see the changes, and unshelf them. Thus I got my files back!

    Perforce Shelf is accessible as a separate menu item

    Open the Version Control tool window and select the "Local Changes" tab. one context option visible upon right-clicking a changed file within that tab is "Shelve changes...". This is equivalent to what I did originally and it will put the file changes in the IDE's shelf. When Perforce is integrated into the IDE project, the option I actually wanted appears as: "Shelve in Perforce..."

    This option will place the files changes in the Perforce shelf (on the Perforce server) and rollback the working directory to the last commit state. The changes are not be visible within the "Shelf" tab of the Version Control tool (as this tab only shows the IDE shelf). To browse the Perforce shelf, go to the "Local Changes" tab of the tool, right click the appropriate Perforce changelist -- looks like <LIST-NAME> - Perforce #<LIST-NUMBER>; x shelved changes -- and select "Browse Perforce shelf..."