damian
damian

Reputation: 3674

What's the Perforce workflow equivalent to this Git workflow? Shelves?

I have done a fairly large refactor, built a binary and submitted to QA for testing. I'd like to start working on a new feature while waiting for QA to come back, with the assumption that I might have to go back and change some things based on QA results.

In Git I would do my refactoring on a branch bigRefactor, make a build based on that, submit to QA, then branch postBigRefactorNewFeature from bigRefactor and continue working. When QA comes back with required changes, I would switch back to bigRefactor, make the required changes, commit, then switch to postBigRefactorNewFeature and either git rebase or git cherry-pick to bring my changes from bigRefactor into postBigRefactorNewFeature.

In Perforce the best I can come up with is to shelve the files I've used for QA on changelist A with description 'big refactor' without reverting locally, move the local changes (now copied to the shelf) to a new changelist B with description 'post big refactor new feature', then continue working. When QA comes back I'll have to shelve what I'm working on in changelist B, revert, unshelve from changelist A, make the required changes, then somehow merge the files from the shelf in changelist B into the workspace.

As far as I can tell there's no way to merge a shelf into the current state of the workspace. How can I do this?

Upvotes: 4

Views: 2061

Answers (1)

Bryan Pendleton
Bryan Pendleton

Reputation: 16359

Yes, you can use shelves as miniature branches using the workflow you describe. Perforce takes case of the "somehow merge the files from the shelf" part.

You can merge changes from a shelf into the current state of the workspace, as long as you have a sufficiently recent server release (I believe this functionality was added in release 2011.1, though it might have been a bit later than that).

You can 'unshelve into open files'; when you unshelve a shelf which has edits to files that you currently have open, Perforce schedules a resolve between the shelved changes and your open files.

The overall process is very similar to other resolves, and is very straightforward to use.

Here's the release note for the new feature.

#299614 (Bug #38221, #39099) **
    Unshelving a file opened for edit over a file already opened
    for edit in the workspace is now allowed. A resolve record is
    created when unshelving, and the user must then run 'p4 resolve'
    to resolve the workspace files with the shelved files. 

Other recent shelving features include the ability to unshelve through a branch spec, and the ability to directly submit a shelved change without unshelving it first. Shelves have evolved quite a bit in recent releases.

You might set up a small test server and experiment with this a bit so that you understand in more detail how it works, and ask more precise questions if the Perforce behavior is confusing.

That said, my own experience is that if your workflow is complicated enough, it becomes confusing to do the "use-shelves-as-mini-branches" approach, and so at some point it's OK to simply make branches. Perforce fully supports branches, of course, even though the precise mechanics are different than git.

Upvotes: 1

Related Questions