How can I use Perforce Shelving to have one person create a change and another person submit it?
Asked Answered
G

2

8

I want UserA to be able to create a changelist in Perforce and then Shelve it. I would then like UserB to be able to unshelve that changelist and submit it.

This sounds simple, but Perforce unshelving doesn't seem to work the way I would expect. When UserB runs 'p4 unshelve -s 1234', it unshelves all of the changed files from change 1234, but it does not bring the change's metadata (description, job fixes) with it! This means that UserB can copy a shelved CL into a whole new CL and submit it (by manually re-creating the description and fixes), but that leaves the old shelved CL hanging around.

The logical thing here would be for UserB to

  1. Unshelve the CL
  2. View the shelved CL's metadata
  3. Copy that metadata into a new CL
  4. Submit the new CL
  5. Delete the old shelved CL
That's what the Perforce documentation even recommends. There'd one little problem: UserB is not allowed to delete another user's shelved CLs! Only UserA and a p4 admin can delete his shelved CL. I don't understand why the documentation glosses right over this.

Has anyone ever had this problem before? How did you resolve it?

EDIT: I should clarify that my question is very generalized. I'm working on a tool where UserA is the developer, and UserB is the build system itself. A developer would shelve a CL and then have the build system unshelve and validate it with a series of builds and tests (automatically submitting the CL if it passed all of those tests). Expecting every developer to remember to delete their shelved CLs if the build system submitted them seems bound for failure!

Gambol answered 19/3, 2012 at 4:16 Comment(4)
I think the trick is that UserA must revert the shelved files after shelving, and then set the changelist's Owner and Client fields to UserB and UserB's client name, respectively. (Or the build system can do that, assuming it has enough privileges.)Thermy
Yes, changing the owner of the changelist is the key point. Once UserB owns the changelist, they can delete it when no longer necessary. This would be a good candidate for a little helper script, which could be put into P4V or even into the broker as a custom command.Doubleheader
I like the idea of a helper script to change the owner. Do you picture this best being a p4 trigger, or a script in p4v, or even a whole custom wrapper?Gambol
Perhaps you could make UserB an admin user. I would think it could delete shelved files from any user.Megalopolis
M
2

What about having the build system send back a notification of success or failure, and letting the developer submit the changelist themselves?

Trying to automate submission of a changelist could get tricky if any files need to be resolved. You might be able to automate some of that, but not if there are any conflicts.

Mitre answered 19/3, 2012 at 14:20 Comment(1)
This is what we do now. We're exploring options for ensuring all checkins are certified before checkins.Gambol
R
1

You might find this feature, introduced in Perforce 2013.1, to be useful:

    #539809 (Bug #53058) **
        Shelved changes containing files that do not require resolve
        may be submitted directly without unshelving first via
        'p4 submit -e <shelvedChange#>'. See 'p4 help submit' for
        details and restrictions.
Ridgley answered 14/8, 2013 at 16:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.