I have a specific use case where I need to create a button (Custom Tools) within Perforce in which it enables the user to right-click a pending changelist with checked out files and it will shelve the files, revert the checked out files, then change the user to a single user and assign the changelist to a specific workspace(The same as the change ownership button)
So far I have set the custom tools to run p4 with the following arguments:
shelve -f -Af -c %P revert -c %P //... change -U **user.name** %P
But this only gets me to shelving the changes, reverting and assigning to a user, I'm missing the workspace change but can't seem to figure this bit out from the docs.
I ran perforce with full logging, which suggested I could run:
p4 user -o **user.name**
p4 spec -o user
p4 client -o **workspace.name**
p4 change -i
But trying to run that locally in a cmd/powershell just outputs the information of the user and workspace.
I am trying to do this to streamline a process as an alternate for manually shelving/unshelving
Use the
p4 change -ocommand to output the current spec, then modify it (you can do this withsedbut the--fieldglobal option onp4makes it much easier IMO), and then usep4 change -ito save the modified spec. This is the general flow that you can use to programmatically modify any Perforce spec (clients, streams, etc).In this case since you're changing the user you do also need the
-Uandchangelist#arguments on thep4 change -icommand.