March 27, 2020

How to Shelve Pending Changes in Helix Core

Version Control

p4 shelve is one of the most popular commands in Helix Core — version control from Perforce. It is great for a number of uses cases and can enhance collaboration across your teams.

Shelving pending changes temporarily stores changes to files that have not been committed back to a server. Developers shelve pending changes to:

  • Collaborate with peers.
  • Transfer code to another machine.
  • Switch projects.
  • Conduct code reviews.
Back to top

How to Shelve Pending Changes in Helix Core

In Helix Core a shelf stores these work-in-progress changes in a “special” changelist, called a shelving changelist.

A changelist groups a set of changes you are submitting to the Helix Core server and gives those changes a number. This number can be referenced in the future.

Magic Behind Helix Core Shelving

What makes the shelving changelist unique is that when you shelve, Helix Core takes the files you are working on and transfers them to the server. They aren’t checked in — or submitted — so the changes you have made to the files are not in version history.

These changes are temporarily on hold. When ready, the changelist can be taken off the shelf, by you or a colleague, so work can resume on those files. The magic is, all of your changes are safe and sound on the Helix Core server. All you have to do is share the number assigned to the shelf with your colleague — who has the correct permissions — so they can access it. Then they can start making changes.

Shelving in Helix Core is so useful because:

  • Files remain in your workspace when shelved.
  • Shelving creates a shelved changelist that can be referenced in your workspace and can be used by others.
  • You can submit files right from a shelved changelist.
Back to top

When to Shelve Pending Changes

So how can shelving work speed up development?

Collaborating with Peers

To transfer work to another team member, you can shelve the files on the server. You can then assign the shelved changes to a new owner.

That user will now see these changes in their list of pending changes. They can unshelve the files into their workspace, keeping them in the same changelist. After working on the files, they can either reshelve (perhaps to return their work to you) or submit the changelist.

Transfer Code to Another Machine

You can use shelving to easily move code from one machine to another. For example, you've done some coding on a Windows machine. But you need to test your new code by compiling it on the Macintosh. You can shelve your files while on Windows, then unshelve them on the Macintosh.

Switching Projects

How about shelving work in progress? You’ve been working for a couple of hours on a feature, and you are interrupted to address work on an emergency hotfix. No problem — just shelve your files. Once the issue has been resolved, you can leave a note in the shelved changelist and restore your workspace, returning to your feature work.

Conduct Code Reviews

Shelving is part of the Helix Core workflow for pre-commit code reviews. Helix Swarm — the free enterprise code review for Helix Core — uses shelving. A Swarm review is created with an id, a description, a set of files, and other meta-data. This includes the author, reviewers and comments made on the review.

Back to top

You Can Shelve Pending Changes In Streams

Shelving also has some unique features that enhance Helix Core’s branching and merging technology, Streams. For example, in addition to code and non-code assets being shelved, p4 shelve also shelves any open stream specification.

For more information on open stream specifications, see p4 stream >>

Back to top

Shelving Pending Changes With Helix Core

With Helix Core and shelving, you’ll uncover new ways to improve your own development workflow, as well as to collaborate with team members. You’ll have the added benefit of shelved files being stored on the commit server, so there is no risk of work being lost.

Start accelerating development.


Back to top