Delete a Perforce client workspace with pending files when the workspace has already been removed from disk

perforceversion control

How do I delete a workspace that has pending files when that workspace has already been removed from disk?

Caveats:

  • p4 command line only; not p4v gui
  • regular user access; no admin access

Scenario:

  • create a workspace named user_workspace on the disk in the ~/my_workspace directory
  • p4 edit files in workspace on the default pending changelist
  • remove workspace by hand (rm -rf ~/my_workspace)
    • workspace still exists on server with pending files

Solutions that don't work:

1: Delete workspace

Doesn't work because the workspace has files opened.

p4 client -d user_workspace

Client 'user_workspace' has files opened; use -f to force delete.

2: Delete workspace with force

Doesn't work because not admin.

p4 client -d -f user_workspace

You don't have permission for this operation.

3: Delete the pending changelist; then delete workspace (try 1)

p4 changes -c user_workspace -s pending

Only lists pending numbered changelists, does not handle the default pending changelist.

p4 -c user_workspace -d changelist_number

Not possible because there is no changelist number for the pending changelist.

4: Delete the pending changelist; then delete workspace (try 2)

Trying to do a p4 revert on a directory that does not exist anymore gives a strange error.

p4 revert ~/my_workspace

/home/user/my_workspace – must refer to client 'user_workspace'.

p4 -c user_workspace revert ~/my_workspace

/home/user/my_workspace – must refer to client 'user_workspace'.

setenv P4CLIENT user_workspace; p4 -c user_workspace revert ~/my_workspace

/home/user/my_workspace – must refer to client 'user_workspace'.

Best Answer

1. Revert the pending changelist

Have to use Perforce depot notation instead of local directory notation because the local directory does not exist anymore.

p4 -c user_workspace revert -k //...

//blah/blah/blah/file#rev - was edit, reverted

2. Delete the client workspace

p4 client -d user_workspace

Client user_workspace deleted.

Related Topic