Reverting Another User's Files
Task
How do you revert files for a user or client that no longer exists?
Solution
There are two ways to revert files opened in a Perforce client workspace not owned by you. Both methods require you have Perforce admin or super privileges.The simplest solution is to delete the client workspace containing the opened files. For example, if p4 opened shows:
//depot/main/www/training/index.html#8
- edit default change (txt) by jim@stlouis
the "stlouis" client workspace can be deleted with:
p4 client -d -f stlouis
Deleting a client workspace reverts all files opened by that client and removes the client's "have" list. However, deleting a client workspace does not remove files stored in the client workspace. To clean up the deleted workspace file system, you must erase the files directly.
You might want to revert a file without deleting the client workspace. In that case, you can impersonate the user that owns the client workspace and then run the p4 revert command. For example:p4 login user p4 -u user -c client -H host revert -k file
The "p4 login user" gives you a login ticket for that user without prompting for a password. Again, only Perforce users with admin or super privileges can use "p4 login" in this way. The login ticket allows you to run the revert command with the credentials of the client workspace owner. In order to successfully run the p4 revert command, it is also necessary to specify the client workspace and host field (if any) using the -c and -H global flags, respectively. Finally, by using the -k flag with the revert command, the file will be reverted without attempting to transfer it back to the client. Without using -k, a revert performs a sync to the client of the previous "have" revision of the file.
p4 revert -k was added in release 2005.2 of the Perforce Server (change #76292). On earlier server versions, the -k option is not available. In that case, a revert of another user's file(s) will only succeed if the impersonated client workspace Root path can be mapped onto your local system. If the Perforce Server is unable to write the reverted file to your client file system, then the revert will fail.
Resetting user passwords
Sometimes impersonating the perforce user and client to do a revert may possibly require a Perforce superuser to reset their password. The admin superuser can simply change the user's password, login as the user, and then revert the files. For example, to reset the password:
Releases 99.1 and later:
p4 passwd username
When prompted, enter a new password for user username.
Pre-99.1 releases:
p4 user -f username
Enter the password in the Password: field of the user specification form.
Locked client workspaceIn case the client workspace is locked, the Perforce admin can use the -f flag option with the p4 client command to modify another user's workspace. For example:
p4 client -f clientname
Superusers may use the -f flag to delete or modify locked workspaces owned by other users, and non-superusers may use this flag to delete or modify locked workspaces that they do own.
