perforce how to cleanup a file opened on a non-existent client and non-existent workspace - perforce

Title says it all.
There's a file that perforce thinks it is opened in exclusive mode by a user on a given workspace and a given changelist, but neither the workspace nor the changelist exists. The workspace was force deleted by an admin, the file mysteriously disappeared from the changelist and then we removed all other files from it and deleted it.
File still shows as being opened and locked by that user on that workspace on that changelist.
Most likely corrupted perforce database, possible solution here, as replied on the perforce forums: https://kb.perforce.com/AdminTasks/BackupAndRecovery/RarelyUsedSe..ommandFlags/P4dXxFlag

Do you know how your admin removed the workspace? According to the documentation, deleting a workspace should automatically revert any files, but leave the local files on the file system, which should be straight forward enough to delete.
If the issue is merely that the file remains locked, then a simple:
p4 unlock -f <file>
issued by an administrator, should resolve the problem.

I had this flag setting after moving a depot to a new server, which I don't recommend.
I created the User back on the new system.
I was able to see the old workspace, which was previously hidden because of filters.
Right click on the workspace, choose edit, and under the advanced tab there is a Host field, that I changed to match the current hostname (including the port - newhost:1666).
Set the connection to the user / workspace
Now the check mark was red, instead of blue.
I selected each marked file, right clicked and chose Resolve by the default safe mode. I forget if the icon changed.
Then I right-clicked and chose Revert if Unchanged, and the icon went back to a "file synced" blue dot. Done.
I hope this makes sense.

This sounds like an inconsistency between the server's db.locks and db.working tables -- deleting the workspace must have deleted the db.working entries but not the db.locks entries (they're always supposed to be one-to-one).
From the server side there are a couple of options to fix this:
p4d -xx db.working db.locks
p4d -jr jnl.fix
or:
p4d -xf 925
It's also possible to go through some gyrations to fix it from the client side:
p4 set P4CLIENT=CLIENT_NAME (where this is the name of the deleted workspace)
p4 client
p4 sync FILE_NAME
p4 edit FILE_NAME
p4 revert FILE_NAME
p4 sync #none
p4 client -d CLIENT_NAME
i.e. re-create the opened file state (same depot file and same client name, so that the keys will match), and then revert it so the entries can get cleaned up properly.

Related

Perforce deleted files from explorer, how to sync?

I have deleted a couple of image files from my workspace through the windows explorer (I left one file in that folder), then I went to my visual client and hit "Get Latest". Nothing happened, I worked through the terminal and did p4 sync -f in the parent folder, nothing was brought back either. I guess because I've deleted the files by hand Perforce wasn't able to relate to those files.
My workaround was:
Checking out those deleted files from the depo (it would warn that the file won't exist)
Revert them. The revert brought back the missing files from the depot.
Is there a better workflow dealing with that?
Use the p4 clean command. This will automatically re-sync everything that is different or missing (or, in the case of extra files that weren't added to the depot, delete them).
https://web.archive.org/web/20150107135057/http://www.perforce.com/blog/140501/p4-clean-make-workspace-shine

I cannot remove a workspace form P4V because its relative folder deleted in windows file explorer

I was setting up a small server to allow my friends to access Unreal Engine documents. I am completely new to this. I accidentally made an extra folder. I didn't notice I didn't need it at the time and made it a workspace. Then I realized and deleted it in the window file explorer. However, as I figured out it did not remove it from P4V.
Now, when I try to delete the workspace in P4V, I get the error message:
"Client 'UE4Workspace1' has files opened. To delete the client, revert any opened files and delete any pending changes first. An administrator may specify -f to force the delete of another user's client."
I do not know how to use -f. What can I do?
According to the error message, you have checked out some files in the workspace which you were trying to delete.
So to fix the problem:
1 switch to the workspace you want to delete.
2 revert these files in your pending change list (Or possibly in other changelist in that workspace)
3 delete any numbered changelists in that workspace.
4 switch to other workspace(this step is possibly optional)
5 delete the problemetic workspace in p4v.
I guess P4 maintains status of every workspace in the server. And to avoid mis-deleting local edited files, they will prevent users from deleting workspaces if the workspaces still have pending files.
Assuming you have the correct rights, you can from a command line, while being logged in the server,
p4 client -d -f <workspace_name>
-d : means delete
-f : means force
A client or a workspace in Perforce speak is the same thing. (I am not quite sure why there are two terms for the same thing.)
Full reference : https://www.perforce.com/perforce/r15.2/manuals/cmdref/p4_client.html

How can I update my perforce have list to reflect my empty workspace on a new PC?

Recently our development team received new pc's. In an effort to make this transition smoother, I would like to be able to explain to my co-workers how to continue using the client they already have set up to pull files to and from the new pc while eventually ignoring the old pc workspace altogether.
I know about adjusting the attributes of the client itself and allowing the client to be accessed by different hosts. What I'm looking to do now is update the perforce have list for the given client to reflect the files (or lack thereof) that are on the new pc's file system (in the correctly mapped location, obviously).
I'm not sure if it is possible with the p4 flush command for perforce to know which revision of an existing workspace file i have without explicitly telling perforce which revision it is...? (this seems like its asking a lot)
Apart from files that Do exist in the workspace, is there a command that will update the have list to #0 for files that don't exist in the workspace?
OR
Is the sledgehammer approach:
submit any pending changes in the old and/or new workspace
remove any files that may have already been forced into the (new) workspace
$:p4 flush [workspace root]/...#0
appropriate in this situation?
If using the existing workspaces is an option, then this should be pretty easy. It sounds like you already know how to make a workspace accessible from a different host (you can leave it blank to make it accessible by any host). If you copy the workspace folder to the new PC, and update the root of the workspace as necessary, it should "just work" without any additional changes.
If I'm understanding your question correctly, I believe that using a workspace name as your revision modifier will do what you want. For example p4 flush //depot/path/some/file#workspacename. For new machines, we often go through these basic steps to avoid having to resync files.
Copy the files in the workspace from machine 1 to machine 2
Create a client that matches the old client's mappings
In the new client, run:
p4 flush //depot/...#oldclientname

Perforce deleting a file from workspace and reflecting that in Perforce

Is it possible to delete a file from your workspace and then hitting submit in perforce and that file being deleted from the perforce server?
open for read: F
\LocalSource\Perforce\MainBranch\blah\New Text Document.txt: The system cannot find the file specified.
Submit aborted -- fix problems then use 'p4 submit -c 4799463'.
Some file(s) could not be transferred from client.
I get this message when I try to submit. In Subversion I could do this. I had a look on the internet and it looks like this isn't possible, but I thought I'd check on here.
(The reason I want this is because I have a spreadsheet and I want to extract the modules from the spreadsheet and put them into source control. But sometimes modules in that spreadsheet may be removed and I want to be able to just checkin the modules that are changed and do deletions on the server, without having to go into the perforce client and deleting the files marked for deletion in there.) One method was to delete all the files in perforce and then do a dummy commit of an empty directory. And then add all the files again extracted from the spreadsheet and do an add. But then in my version history I always will have a version with a full delete.
Any simple ideas, special commands that I can use?
Thanks,
Chris
If you delete files directly on disk, without using the Perforce client to delete them (e.g., you use your spreadsheet command to delete those files directly), that's called "offline work", and in order to tell Perforce that you've made those changes, you just need to go back into your P4V window and use "Reconcile Offline Work".
See Working Disconnected From The Perforce Server for complete instructions.
See also this related question: Sync offline changes to a workspace into Perforce
Perforce has a command-line client (http://www.perforce.com/product/components/perforce_commandline_client) you should be able to execute from Excel as any exe file via the Shell function.

How do I delete a file from depot, but leave local copy in tact?

I'm trying to learn Perforce and want to delete a file from the depot(easy to do with p4 delete, p4 submit), but that deletes it from the client machine dir structure as well. I want to keep my local file in my directory intact.
The only way I can see to do this would be to move it out of the hierarchy that is under Perforce control before deleting. I was able to get my file back by syncing an earlier version.
Maybe I set up my client workspace wrong? Or am I misunderstanding a fundamental concept of source control? The client workspace is /home/user and I did it this way so I could add any file under my home directory without getting an error about the file not being under client's root.
FYI - Linux client and server running P4D/LINUX26X86/2009.1/222893 (2009/11/12)
Any advice appreciated.
Thanks.
There is a way to do this, by going behind Perforce's back. Do the following:
Rename the file you want to delete to something new
Run p4 delete on the original filename
p4 submit the change
Rename the file back to the original name
I don't believe there is any way to keep a file you are deleting under Perforce. There is good reason for this, as if the file is deleted in the depot there is no reason (from a source code control perspective) to keep a copy in the client workspace.
I suspect the issue is the way you are using Perforce.
From what you have written it seems that you are using Perforce to backup/track files in your home directory structure. So the way you are using Perforce the "master" is in your home directory and the "copies" are in the depot.
This is not the intended use of a source control system as I understand it.
The master copy of all files are actually what is in the depot. From the depot, multiple clients (views) are made for purposes such as making changes, testing, and so on. The clients are transitory and can be created and deleted as required.
To do what you want to do you may need to rethink how you are using Perforce.
some of the other commands take a parameter that lets you fake the action, but delete doesn't. You could always make a new client, do the delete in that workspace.
In the Workspace tab go to folder containing file(s) to remove from source
Right-click on that directory (or from File menu) and choose Open command window here
Note - If you open your own command prompt in the source directory you may encounter this error:
"Client 'your-client' unknown - use 'client' command to create it."
Enter command p4 delete -k <file_to_delete>
Change will be added to your P4V Helix changelist ready to check in

Resources