How to reconcile newer workspace files with depot in Perforce? - perforce

I have a situation where my depot is saying it has the latest version of a bunch of different files but my local workspace actually has newer revisions. My tools (P4V and VS plugin) are incorrectly telling me that everything is up-to-date.
I can prove this is the case because if I check out the file, make no changes, and submit, the changes are committed and the history appears correct and get latest operations on other machines pull the correct version of the file.
This isn't really a viable solution as there could be many files that require this fix and I have no way of knowing I have fixed them all.
I believe the issue has come about due to occasionally working offline and (incorrectly) twiddling the read only flag on the file when I needed to make a change.
So my question:
Is there a command (or similar) I can run that will look at my workspace files and see that there is a change that hasn't been committed. Essentially ignoring the 'reported' state of the file? Something like sync but in reverse? This would allow me to 'force commit' all those files and get the depot in the correct state.

The command you are looking for is called 'p4 reconcile'. Here's some background information: Working Disconnected from the Perforce Server.

Related

How do i download a whole project from perforce onto a device?

So, to give some context. Recently i had to delete the whole project from my personal computer for some reasons. Now i want to download the whole project back onto my PC but don't know how. I assume that the clone button would do that (since that's what it does on Git) but seems to not be the case. I then tried to force update all the files thinking it would download the missing ones. It kinda works, i think but it takes awfully long. It took around 16 hours to update a folder that was about 20GB in size.
The project in question is a UE4 project, in case that's important
Now the question. How can i, most easily, download the whole project from perforce onto my PC? Thank you for your help in advance!
In the future, you can simplify this by using Perforce's "remove from workspace" or p4 sync #none command to delete the project from your PC. If you use Perforce's commands to clean up the workspace, it will:
not delete anything that isn't backed up to Perforce (i.e. files you didn't add to Perforce will be safe)
keep track of what you deleted (so the next time you do a normal "sync" it will just put it all back, without the force flag)
In the situation you found yourself in, an option apart from "force download" is the p4 clean command, which will reset your workspace's state to whatever you last synced to. Note that this will not necessarily preserve any local changes, but if you delete the entire workspace root this isn't a concern.
The time it takes to re-sync a folder is largely a function of your network speed to the Perforce server, but in some cases can be improved by parallelization (I believe P4V will do this automatically, and it's easy to enable via the command line, but if you're syncing via the UE4 plugin this may not be the case). https://community.perforce.com/s/article/9064

Perforce reconcile offline work doesn't notice the changes

So, I created a new file and copied it over the one in the workspace. Then I selected "reconcile offline work" from the context menu of the directory containing the file, after I've updated the directory and made sure the workspace has the new version of the file - but Perforce says that no files have changed.
There is one more weirdness in this: Despite having the latest version of the program, both the p4 and p4v clients, perhaps, because of the server version, I don't have reconcile command available (I don't know what version is the server, and don't know how to find it out).
So, it would help if you could tell how to do the same thing as reconcile, while not having this command (it seems to be a newish addition, but I cannot imagine a workflow that doesn't require you to use it, or something that does the same thing). The VCS is practically useless if it cannot figure out on its own what files had changed since the last version...
If your server is older, and doesn't support reconcile, there are other ways to accomplish these tasks. Start here for all the details: http://answers.perforce.com/articles/KB_Article/Working-Disconnected-From-The-Perforce-Server
If you added a file to Perforce and copied it to another workspace you will need "p4 sync -k //depot/path/to/file" to reflect the change.

How can i release checked out files locally in perforce

I am new to perforce. I need clarification on the below.
I have created workspace and by mistake i have checked out the entire project(all files). I have not done any changes in the local workspace. After some days i tried to get latest revision from the server it shows some merger conflict error.
Now, How can i release the checked out files without affecting remote files. Will it affect remote files if i do revert operation locally.
Thanks for your kind advice.
Selva
If you haven't made any changes then simply reverting the checkout will "release the checked out files". This will not affect any files checked out or modified elsewhere as it is simply an operation that works on your copies of the files.
Any operation you can do will only affect your local copies and the files in the depot. You cannot directly affect files on other people's machines.

Perforce not syncing files correctly

I'm using Perforce P4V, the graphical tool, to interface with my Perforce server here at work. I have a project I added to the depot and I accidentally deleted it from my workspace on my local computer, problem is when I use the Get Revision Action (the GUI equivalent of sync), the files don't get updated, i.e. I can see the files on the server that I want, but they won't sync correctly with my local PC. It's frustrating me that the files aren't getting pulled from the server. What I'm assuming should be happening is if files are altered in anyway on my local PC, I should be able to grab the revision from the server, which then pulls the data to my local PC and overwrites the changes locally on my PC, but that isn't happening. Is there something I'm missing?
Perforce keeps track of the files that it thinks that you have on your local workstation. If you delete those files locally (and don't "tell" perforce about it), then Perforce will still think that you have those files. If you want to get them back, you need to "force sync" the files. In p4v, you can use the "Get Revision..." item and in the subsequent dialog, you can check the "force operation" checkbox to tell Perforce to give you all the files again regardless of whether Perforce thinks that you need them.
Just to complete the information, if you ever do want to remove the files locally, you can do so through p4v by choosing the "Remove from Workspace" item. Doing so will remove the files locally as well as tell perforce that you no longer have those files so that next time you sync, those files will be retrieved from the server.
Like other people have mentioned, one solution is to do a "force sync" the entire depot which is basically overwriting everything from server into your local. The downside to this is that it could take a LONG time to finish if you are working on a big depot.
Another alternative is to compare your local workspace with the server, then only force sync the files that are missing from your workspace.
p4 diff -sd //Depot/path/… | p4 -x – sync -f
-sd option: Show only the names of unopened files that are missing from the client workspace, but present in the depot.
There are more options (sa/se/etc.) available if -sd is not what you need. see here.
credits for the command goes to this blog.
They won't update because according to Perforce you still have the files on your local machine.
You need to use the "Get Revison..." option and enable the "Force Operation" option.
This will tell Perforce to refresh all the files even those it thinks you have the latest version of.
"Get Revision" will update only files that are not opened (checked out) even when "Force Operation" is enabled. You should revert all files marked as checked out in that workspace, and then use "Get Revision" with "Force Operation"
I did as you suggested, but I kept getting the message that the files were still open for edit and cannot be deleted, when trying Remove from Workspace.
Also, Get Revision returned with a message that no files were updated.
What I ended up having to do was Revert the files, then do the Get Revision action, that solved the problem.
For people coming into this question, this worked for me on the mac command line ...
cd into your local perforce workspace - the base directory of the checked out files that you are working on.
p4 sync -f
-f is to force the sync.
This can also come in handy when you restore a mac from a time machine backup.
https://www.perforce.com/perforce/r12.1/manuals/cmdref/sync.html
Check out the file, change it a little bit and then revert. Perforce will replace the local file with the latest revision.

Need to recover local changes overwritten by p4 revert

I had a pending changelist in my workspace.
By mistake I reverted one of the files by reverting to depot. Eclipse wiped off the local history. I am not sure if perforce keeps any history for pending changelists.
Is it possible to recover such file?
The simple answer (to my knowledge) is "no". Perforce doesn't keep a history for (non-submitted) changelists.
Unless you happen to be on an operating system that offers snapshots (or your file-server does), you are out of luck.
Another thing you might try for the future is to get in the habit (e.g., by defining a local alias) of always using 'p4 revert -a'. It would be nice if 'p4 revert -a' had been the default, and you had needed to pass a special flag to indicate that you wanted to revert a file that you had locally changed, but that's not the way it currently is, unfortunately.
I was also facing the same issue. my workspace over written from cvs by mistake and I lost all the changes in some of my local files.I found that in eclipse UI resource history has shown as blank for the files but the history file created by the eclipse still exist in *$eclipse-workspace.metadata.plugins\org.eclipse.core.resources.history* folder. Use any text editor like notepad++ to search for the name of your file in all the folders and you can easily recover the file from there. I just did the same to recover my files.
If Visual studio is the IDE undo under edit menu recovers the files
Drive snapshots are your best bet to prevent this in the future. For my personal non important projects, I use a Git for checkins; but dropbox for easy multi-machine work and snapshotting of non checked in code (even to local repo)
The only solution is having backups/snapshots. If you're in a corporate environment, contact your IT department.
If you are in a unix corporate environment, you might have a ~/.snapshot directory that keeps hourly snapshots of all your files for the last few days.

Resources