Perforce Public Knowledge Base - Deleting a changelist with shelved files
Reset Search
 

 

Article

Deleting a changelist with shelved files

« Go Back

Information

 
Problem

A changelist cannot be deleted if it contains shelved files. For example:

p4 change -d 523
Change 523 has shelved files associated with it and can't be deleted.

How can I delete a changelist with shelved files?

How can I save copies of shelved files before deleting a shelved change?

Solution

A changelist containing shelved files cannot be deleted; you must first delete those shelved files. 

Deleting files shelved in your workspace

To list files shelved in a given change, you can use the p4 describe command:

p4 describe -s -S {change number}

The upper-case '-S' flag shows files that are shelved in this changelist, if any.

For example:

p4 describe -s -S 7033
Change 7033 by norman@graze on 2014/04/08 20:40:01 *pending*

        shelving a file

Shelved files ...

... //depot/source/file0.txt#4 edit

To delete the shelved files, use p4 shelve -d followed by the change number:

p4 shelve -d -c 7033
Shelved change 7033 deleted.

Having removed the shelved files by deleting the shelved change, you can remove the changelist itself:

p4 change -d 7033
Change 7033 deleted.

Deleting files shelved by another user or workspace

The changelist containing shelved files can be associated with a different user or client workspace. Deleting such files requires impersonating that user or workspace. Alternatively, deleting files shelved by another user can be done by a user with 'super' or 'admin' permissions.

A user with 'admin' access can delete shelved files by adding the -f flag to force the operation:

p4 -u admin shelve -d -c 7202 -f
Shelved change 7202 deleted.

The user and workspace can be determined by inspecting the change using the same p4 describe syntax as above:

p4 describe -s -S {change number}

Alternately you can walk through the errors generated when attempting to delete the shelved change without the -f option:

p4 shelve -d -c 7202
Change 7202 belongs to client min-graze.

The workspace (P4CLIENT) setting can be impersonated by adding the -c global option with the workspace name to the command:

p4 -c min-graze shelve -d -c 7202
Client 'min-graze' can only be used from host 'min'.

The min-graze workspace is tied to a specific host, min; Add the workspace host name to my command using the -h global option:

p4 -c min-graze -H min shelve -d -c 7202
Change 7202 belongs to user norman.

Use the -u global option to add the user name:

p4 -c min-graze -H min -u norman shelve -d -c 7202
Shelved change 7202 deleted.

Note: You may need to login the user in order to delete the shelved file using this method. While logged in as a super user, enter the command:

p4 login {user name}

For example:

p4 login norman

Change has shelved files, but user no longer has access/can see the files

Sometimes a change in protections means a user is no longer allowed to access a file they have shelved. To unshelve these files requires either a change in the protections table (requiring a super user) or, more conveniently, an admin user to run the p4 shelve -d command. For example, user 'norman' shelves a file:

p4 -u norman shelve -c 7202 //depot/source/file0.txt
Shelving files for change 7202.
edit //depot/source/file0.txt#5
Change 7202 files shelved.

The protections table is updated. The pending change containing those shelved files still exists:

p4 -u norman changes -s pending -c min-graze
Change 7202 on 2014/06/16 by norman@min-graze *pending* 'Shelving a file in this change '

But the owner of that change cannot delete the change nor view the shelved files in that change:

p4 -u norman change -d 7202
Change 7202 has shelved files associated with it and can't be deleted.

p4 -u norman describe -s -S 7202
Change 7202 by norman@min-graze on 2014/06/16 11:12:23 *pending*

    Shelving a file in this change

Shelved files ...

[ no files listed ]

An admin user can view and delete the shelved files:

p4 -u admin describe -s -S 7202
Change 7202 by norman@min-graze on 2014/06/16 11:12:23 *pending*

    Shelving a file in this change

Shelved files ...

... //depot/source/file0.txt#5 edit

p4 -u admin shelve -d -f -c 7202
Shelved change 7202 deleted.

... which allows 'norman' to delete his pending change.

p4 -u norman change -d 7202
Change 7202 deleted.

Viewing or saving a shelved file

Use the p4 print command to save local copies of shelved files prior to deleting the shelved changelist. For example:
 
p4 print -q //depot/source/file0.txt@=7202 > shelve_7202_file0.txt
 
Related Links

Feedback

 

Was this article helpful?


   

Feedback

Please tell us how we can make this article more useful.

Characters Remaining: 255