I want to get the list of files that has been changed on server since last sync down on a particular branch.
I want only the files that has been changed/added on the server. I am not at all concerned with the locally changed files.
p4 sync -n shows you the files that will be synced.
p4 sync -N gives you a summary.
Related
I have a bit of a curious problem I've never run into before.
A student of mine deleted a depot from the workspace, but did not submit the changes. He then subsequently deleted his workspace (and all associated changelists). So this is now our situation:
marked for delete on depot
Workspace files marked for delete
How can I clean up this tag?
1) I replicated the work directory on another drive, deleted the workspace files (and submitted, deleting them off the depot as well).
2) Copied all the files from the backup, marked for add, then resubmitted
RESULT: They came back, still tagged for deletion.
I tried reverting individual files and entire directories (no luck).
I can't revert to a prior changelist, as the changelist in question is still pending.
Any ideas on how I can clean this up?
Thanks in advance!
I don't think the user actually deleted their client. Run p4 opened -a on the file(s) in question to see what client they're open on:
C:\Perforce\test>p4 opened -a //depot/...
//depot/main/bleh#1 - delete default change (text) by Samwise#classic
I can see in this output that the file is opened for delete on the client classic. Does that workspace still exist?
C:\Perforce\test>p4 clients -e classic
Client classic 2020/03/24 root c:\Perforce\test\depot 'Created by Samwise. '
Yes it does. Can I delete it? Yes, as long as I'm an administrator:
C:\Perforce\test>p4 client -d classic
Client 'classic' 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.
C:\Perforce\test>p4 client -d -f classic
Client classic deleted.
Is the file still open?
C:\Perforce\test>p4 opened -a //depot/...
//depot/... - file(s) not opened anywhere.
No it is not.
I just created a new workspace. I am getting "Can't clobber writable file" error while doing p4 copy from a branch to another. Concerned file has been deleted on source branch. I did not touch concerned file. Even doing p4 sync -f before p4 copy command does not help. What could be issue ?
See How to fix Perforce error "Can't clobber writable file" or Perforce Error Message - Can't Clobber Writable File for more information on the "can't clobber" error in general.
In the specific case you describe where you just made a new workspace, my guess would be that you made the new workspace in a folder where files already existed locally (maybe on top of an existing workspace?). If you did create this workspace folder on top of an existing workspace, stop and pick a new root folder for this workspace; the other workspace won't "know" that its filesystem is being modified by the operations you do in this workspace, and when you switch back to that workspace everything is going to be bad (you might find that you've lost pending changes, sync won't be fetching the right thing unless you force-sync everything, et cetera).
If messing up another workspace isn't a concern, just do:
p4 clean
and once that's done your p4 copy should work.
The file is writable on your local machine. p4 is trying to protect you from getting rid of a file you might have edited.
Since you say you created a new workspace, I'm assuming it contains the same root as your previous workspace. If you know you want to get rid of everything, you can manually delete those files and retry your p4 sync -f or the hand p4 refresh.
I am trying to automate access to Perforce via it's command line utility.
Creating a new client workspace with p4 client and syncing works ok.
Now I am allowing users to overwrite user, host, port, stream, revision.
From the docs it is not clear to me when I have to execute which commands to get the client workspace files in sync with an edited client workspace spec.
What I currently do is once p4 client is through search for
Client mymachine not changed
in stdout and do a p4 sync -f should the message not appear.
Is there a better or more sane way to do this?
I tried executing e.g. p4 sync -s in hope that it would fail should local data be deleted but it seems that I misunderstood the option?
It is not clear to me how this relates to your question about workspaces:
Now I am allowing users to overwrite user, host, port, stream,
revision.
since only one of those is a property of a workspace. I'm going to disregard that statement for now but if it was significant I'd encourage you to post a follow-up clarifying what you mean by "overwriting" each of these properties.
To your question:
From the docs it is not clear to me when I have to execute which
commands to get the client workspace files in sync with an edited
client workspace spec.
If the client View is updated, all you need to do is:
p4 sync
If the client Root is updated, or any of the other options that globally affect how files are written to the workspace, such as allwrite or modtime, you will need to re-sync the entire client. Ideally this is done by doing:
p4 sync #none
prior to changing the workspace in one of these ways. The other option would be to do something like the following sequence:
p4 sync #none
p4 sync
p4 clean
to make sure that everything is rewritten, and that any stragglers (e.g. anything that the "sync #none" couldn't locate because the Root had changed but that are still mapped in the client view) are removed from the workspace.
I tried executing e.g. p4 sync -s in hope that it would fail should
local data be deleted but it seems that I misunderstood the option?
Deleting local data is a separate issue from editing the client spec, but for that the command you want is p4 clean rather than p4 sync -- you use sync to tell the server you want it to send you new revisions, you use clean to bring your workspace back in line with what the server already sent you.
The recommended/supported workflow is to always use p4 commands to manipulate the read-only files in your workspace -- so if you want to delete a local file, use either p4 sync FILE#none (to remove it from your workspace but not affect the depot) or p4 delete FILE (to open it for delete so that it will be deleted for everyone when you submit).
I am writing a build script that gets all the source code for a particular changelist and builds it. I would like to be able to run the script at any time, without having to shelve local changes or move files to a temporary location. The script will be used by others who have their own workspaces defined.
I thought it would be easiest just to get all the source code from Perforce at a temporary location and build from there. Unfortunately p4 sync does not seem to support this, it will only put files into the client view as specified by the workspace, meaning it would overwrite local changes before I could copy the files to the temporary location.
Is there any way to use p4 to copy files from Perforce into an arbitrary location?
You could create a dedicated workspace for the build script and then have the build script sync to it by using
p4 -c [workspace name] sync [depot path]
This is what a continuous build system would typically do. Be sure to blank out the Host: section of the workspace spec in this case so that it can be used on multiple systems.
An alternative might be to use p4 print with the -o option to dump the files to an arbitrary location without syncing them.
P4 sync can be done only to a client spec. Possibly, you need to create another client spec and sync to that client spec.
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.