how to sync p4 from a backup of a workspace - perforce

I've got a very large depot synced to my workstation, I'm trying to get a few more computers up to date without requiring them to sync as well. We've copied over all the files from my computer into their working directories and are trying to get perforce to recognize that they already have these files at a specific revision.
It sounds like flush is what we're looking for, but it doesn't seem to be working. What I'm trying is:
p4 flush //ourdepotname/...#123456
However nothing changes. If I add:
p4 flush -f //ourdepotname/...#123456
then I'll see all my files are recognized as version 0/x in p4v now.
Is flush not what we need? How can we get P4 to recognize that we already have all the files locally at revision 123456?

I was indicating a revision when I meant to indicate a change list.
p4 flush //ourdepotname/...#123456
Thanks to Sam Stafford for clarification.

Related

Update have list to reflect local working copy

I deleted a large folder I no longer need from my local workspace, i.e.
//binary_blobs/.... Now Perforce (command line) is complaining about the
missing files, i.e.:
test.raw - submit change default to delete //binary_blobs/test.raw#1
My goal is to tell the remote server that I've locally deleted the files, and
that the server/depot copy should be left alone. Essentially, I want to update
the "have list" so that it knows I no longer possess this 200GB folder of binary
data. I ran p4 flush //binary_blobs/..., hoping it would resolve the issue,
but nope: p4 is still locally tracking these files.
So, I decide I'll just tell it to sync this folder at #0 to remove the local
copies of the files via p4 sync -f //binary_blobs/...#0, but this fails too
due to:
//binary_blobs/test.raw#1 is opened for delete and can't be deleted
Argh! Looks like I have to revert my changes:
p4 revert //binary_blobs/...
Now it's RE-SYNCING all the data over the network again, which will takes days.
Question
Can I tell Perforce, via the command line, to just update the "have list" based
on what I locally possess, without re-pulling the entire depot from the remote
server?
Finally figured it out. First, I revert while keeping the workspace files as-is:
p4 revert -k //binary_blobs/...
Now I can update to revision #0:
p4 sync -f //binary_blobs/...#0
Saved me from having to manually re-create my workspace.

Copying a Workspace/Folders by USB instead of Getting Latest Revision Online

I have a pretty huge project that I host on an external Perforce server. The project is about 13GB.
I have setup a new machine and want to transfer my workspace to the new machine. Copy/Pasting by USB and indicating to perforce that these are the same files seems to not work.
Syncing directly with the server (get latest revision) will take a very long time (slow download speed on my end, 13GB of files).
I am using P4V and am familiar with the P4 command line. Is there anyway I can move over my project in an "offline" matter?
I assume you've already copied the files over and created a client spec that maps them appropriately. Once that's done, I would use the command line and do:
p4 flush ...
p4 clean -n ... (just to make sure I'm not about to force-sync the world)
p4 clean ...
The "p4 flush" is how you tell the server that you "have" everything at the head revision; the "p4 clean" asks the server to double-check and make sure that you actually have everything you just told it you have (and nothing else), and fix anything that's different.
If the "p4 clean -n" shows that everything is about to be "added" to the workspace it probably means the mapping is off; if everything is being "refreshed" it means the files are in the right places but they look different now compared to the head revisions, which might be a problem with P4CHARSET (for unicode files) or LineEnd (for text files).
Another variation could be to specify the time of the USB backup on the "p4 flush":
p4 flush ...#yyyy/mm/dd:hh:mm:ss
which will probably result in the "p4 clean" having absolutely nothing to do, which is good; then a normal "p4 sync" will get you up to date with whatever got submitted since you made your backup.
See this blog post for more on the "p4 clean" command: http://www.perforce.com/blog/140501/p4-clean-make-workspace-shine

How do I download files from perforce to a location other than a workspace?

I want to get files from Perforce without putting them into a workspace.
E.g.
I have made changes in 2 files.
file1.cs
file2.cs
Now I want to build the project using updated file1.cs, so I want to get latest files except for file1.cs.
I thought I will get another local copy of project and build it.
I'm not sure what you really want to do, but you can get the contents of a file from the depot without using a workspace definition by using "p4 print". Example:
>p4 print -o fileName.cs //depot/path/to/fileName.cs
As far as I am aware you cannot sync files from a Perforce depot without using a workspace since this is the way it tracks what version of files you have in your workspace and also where to put them on your local machine (as well as a few other things).
I'm not sure I entirely understand your problem but if what you need to do is get another copy of the file1.cs you have in the depot without removing the changes you have to it you can simply copy the changes to another location or shelve them and re-sync the file. The more complete and less dangerous solution is to create another workspace pointing to a different physical location on your machine but the same depot location.
This explains how to create a workspace if you need it:
http://www.perforce.com/perforce/doc.062/manuals/boilerplates/quickstart.html
Make sure the 'Root' path is different to that of your current workspace, you can check what your current workspaces root is by going to the workspace tab in P4V and viewing it.
Once you have created the new workspace create a new connection and select it then sync the file(s) you need.
So I want to get latest files except file1.cs
You shouldn't do that; you should update all files and resolve any conflicts with file1.cs
Consider the situation where someone else has made changes to file56.cs that relies on changes also made to file1.cs. If you take their changelist but overwrite (or do not take) their file1.cs, then your build will break.
Shelve file1.cs so you can safely revert your local change:
p4 shelve file1.cs
p4 revert file1.cs
Now you can do your build with whatever version of file1.cs you want (you can sync back to an older version or whatever).
When you're ready to return to your change:
p4 unshelve -s CHANGE
If you're in the UI you can use File->Export To... which will copy the selected file to any folder you want.
I found the workaround but not the solution.
I get another local copy of project then build the project and submit the change.
I found an easy way of doing this with git:
$ git p4 clone //depot/your/folder

How to do a fast and safe sync on perforce?

If you do a sync in perforce it can happen, very often, to do nothing even if it should. If you do a forced sync (sync -f) it will definitely sync all the files from the server blindly and this is unacceptable if you have a big project.
The question is how can you do a fast sync?
The key part to your question is "even if it should". Without fail, in all my (too) many years of experience with Perforce, users who revert to forced syncs habitually, because a normal sync does not do what they expect, are not using Perforce correctly.
You must let Perforce manage your hard disk for you - the server knows which versions of which files you have, and so a normal sync just gets what it needs. If it fails, then that is almost without exception a sign that the user is modifying, deleting, adding, renaming files outside of Perforce (e.g. in Explorer).
Sometimes you may get a system funny (i.e. PC fault, ) that causes this, so it is not necessarily the users fault. But these are very rare - hence my "habitually" qualifier above.
If you think, hand on heart, that you are not doing anything out of the ordinary, then start to look at what other processes could be tweaking these files. E.g. does you build system do something odd, and try to modify files as it builds? Do you have an open network share that perhaps someone else is inadvertently poking? Do you have a backup system that is interfering?
Hope that helps.
As mentioned by the other answers, you need to create a separate client (workspace) for every "instance" of a directory tree synced from the depot.
If you want to force-sync only those files that have changed from the depot:
p4 diff -se ... | p4 -x - sync -f
p4 diff -sd ... | p4 -x - sync -f
Warning: that will overwrite any locally changed files (in the current directory and subdirectories).
If instead you edited some files and forgot to open them for edit first, you can do this:
p4 diff -se ... | p4 -x - edit
which will open for edit any file that's different from the depot.
And this:
p4 diff -sd ... | p4 -x - delete
will open for delete any file that was locally deleted.
If you create an inconsistency, where perforce looses track of what is going on in your workspace, you should use the "Reconcile offline work..." function (in P4V).
This will run a folder diff and tell you what options you have to resolve the inconsistencies.
In general, make sure that you always check out files explicitly through perforce (open for edit). This feels strange if you are used to other systems.
I believe that the command you're looking for is p4 clean.
From: http://www.perforce.com/perforce/r14.2/manuals/cmdref/p4_clean.html
"Files present in the workspace, but missing from the depot are deleted from the workspace.
Files present in the depot, but missing from your workspace. The version of the files that have been synced from the depot are added to your workspace.
Files modified in your workspace that have not been checked in are restored to the last version synced from the depot."

In perforce, how do I remove pending changes for NEW/ADDED files not submitted?

I am trying to remove a pending changelist in perforce. All the files (20 old) are new but have not be committed/submitted yet. So in p4Win, they show a RED + cross. I am failing to remove these files from the change list. How do I go about getting rid of these files?
Thanks for the answers to right-click and revert. I have tried that but it fails with the example error strings below.
Operation: user-revert
Librarian digest source/.../foo.c failed.
RCS checkout 1.715484 failed!
RCS no such revision 1.715484!
//source/.../foo.c#1 - was add, reverted
I've also tried the p4 revert command but it fails with same error(s).
Fixed with "revert -k" by perforce support group. They suspect it may be due to overlay values in the client workspace but have not been very specific.
How are you trying to remove the files?
It's been a while since I used Perforce in anger but I seem to remember that you just had to right click and revert the file.
I've just tried this and it worked OK for me (the programmer's lament!). It uses the following p4 command:
p4 revert //depot/test.txt
Where test.txt is the name of the test file.
Update
Does the new file still exist locally on your hard drive?
Does the path where the file would be in the depot still exist? ie. what's in the "..." of your path.
Revert files, right-click on file in change list and select revert, this will remove added files.
Maybe try Perforce support at this stage.
To remove all added files in current and sub directories:
p4 revert ...
In my case this happened because the RCS files (the actual files with ,v extension in the depot that contain all the revision information) were literally missing the information for the revision in question. I was able to restore the files from backup.
I had the same problem, I had added the .exe files but wanted to exclude them afterwards. The perforce documentation helped:
http://www.perforce.com/perforce/doc.current/manuals/p4eclipse/topics/adding.html
Excluding Files from Source Control
Important: you cannot exclude files after you have placed them under
Perforce control. If you have files opened in a changelist and you
want to exclude them from Perforce control, revert them from the
changelist before excluding them.
Worked like a charm.

Resources