Perforce-P4 sync query-new work space - perforce

I have synced files around 1 Tb from one server to another and set up P4, but I have a different workspace in the new server so if i initiate a p4 sync in new server, Will it add only the difference or will it duplicate the files?(source remains the same)

If the workspace map is the same as the old client, and there have been no changes, you can do a p4 sync -k. This updates the metadata on the server, without doing the file transfers. If there have been changes, you'll have to force sync those files to get the correct revision.

Since you created a new workspace, and P4 doesn't know that you have the files already existing on your new environment, it will pull over all of those files.
If you kept the same workspace name, (by default) it would pull over only "new" files (because it thinks you already have the files you previously synced).

Related

How to let P4 new worksapce find what have been downloaded already?

My question is:
I have downloaded all files before, then I switch to a new P4 Account, So I got a new workspace. But how can I use the file I have downloaded already with my new workspace? Do I need to redownload all files?
Multiple user accounts that are logged in on the same machine can use the same workspace. If you're using the same physical files, you should be using the same workspace rather than creating a new one which shares its Root.
If you have a copy of the files from the original workspace and want to use those to bootstrap the new workspace, you can do this with p4 flush and p4 clean. But you do not want to define multiple workspaces on the server that share the same physical Root on the client; this will never work well, just like you don't want to use multiple physical Roots with a single workspace definition. They should always be one-to-one.

Can I get files from "Depot" without a "Stream" in Perforce P4?

So I've been reading the helix-core documentation for the p4 command line tool because I cannot use the visual client on my current machine. I am trying to get a way to get the latest files from the local depot on the server, which stores the project me and my team are working on.
I have found the sync command but it requires a stream. I never had to define one when I set up the visual clients for the team or the server if I recall correctly and so if I had one I couldn't find it. The administration tool only shows me the depot like this: //depot/myFiles, which is the default local depot that is created when the server is created if I'm not mistaken. So I've been wondering if it's possible to just "get latest" like in the visual client without a stream or how I can find the stream this depot is using.
tl;dr: the thing you want to make is a "workspace", not a "stream". Run p4 client to create a workspace.
Depots come in two basic flavors in Perforce: stream and local (aka "classic"). The type of a depot is set when it's created by the Perforce admin. One server can have any number of depots.
In a stream depot, files are organized into streams, which by default take the form of top-level depot directories, e.g. //stream/main and //stream/rel1. Streams can be configured to represent files beyond what's in the actual depot directories, but in their simplest form each stream just corresponds exactly to a directory in the depot, including one mainline stream and usually many other streams that are branched from the mainline. Every file in a stream depot is inside a stream. You can run the p4 streams command to see a list of all the streams.
In a local depot, there are no streams. You can add any file anywhere. Usually files are organized into parallel top level directories that are branched from each other, e.g. //local/main and //local/rel1, but there are no guard rails that steer you toward this.
In any kind of depot, you need to create a client workspace to sync and submit files. Each workspace has a client view which creates a mapping between depot files and workspace files; the client view takes depot files and puts them into your workspace when you sync, and it takes workspace files and puts them into the depot when you submit. Each workspace is unique to a particular directory on a particular client machine (the client root) -- you must create a new workspace for each local machine you do work on!
In a stream depot, when you create a workspace, you specify the Stream that you're going to work on. A client view is generated for you automatically that maps your workspace root to the files in the stream. You are not allowed to modify this view manually; if you want to change the view, you need to change the stream, and this will automatically update the views of all clients associated with that stream (so one stream may have many clients, but they will always share a consistent view -- the main function of streams is to centralize client view management).
In a local depot, when you create a workspace, you define a View yourself. By default, when you create a workspace on a server that has a single local depot, the client view maps the entire depot to the workspace root. You can edit the View yourself to map arbitrary paths in the depot to arbitrary paths within your workspace, so you have complete control over which depot files you sync and where each one goes.
To create a client workspace from the command line, run:
p4 client
This will open an editor that contains the client spec. Edit the Stream or View field appropriately. Note that the default name of the client workspace is the hostname of your client machine that it lives on; if you want to change this, run p4 set P4CLIENT=your-client-name before running p4 client. Save the client spec, exit the editor, and you'll see a message like "client saved".
Now you can sync:
p4 sync
This will use your current client spec (the one you've just defined) to sync files from the depot into your workspace. You only need to create the client spec the first time you set up a new client machine, but you can run p4 client again at any time to modify it.

Perforce files all deleted

I'm new to using perforce. I was just copying files to perforce to the server for version control and sharing files. Although those 36 gigabytes of data were gone. All disappeared from my disk, nowhere to be found and reverting did not work. So is there anything I could do to restore my files?
If you submit files to Perforce, the server has safe copies of them, and you can get them back at any time just by running p4 sync.
End users are not permitted to permanently delete submitted files from a Perforce server, so under most circumstances once you submit something to Perforce it's safe forever.
Normally the administrator of a Perforce server will maintain backups so that even if the server is compromised somehow (e.g. a hardware failure or an admin mistake), the files can be recovered.
Some basic troubleshooting steps:
Does the server think you already have the files because you deleted them from a synced workspace without opening them for delete? Try p4 clean to restore your workspace to the state that you last synced/submitted.
Are the files deleted at the head revision? Try syncing to an older revision.
Did the files ever make it to the server? Try p4 files //... to see a list of all the files on the server.

Perforce will not delete files and folders from Depot

I have a workspace that some files and folders were deleted offline. The workspace shows them there on the depot side. No matter what I do, I cannot get it to remove those files/folders. When I select "Mark for Delete" is says "file(s) not in client view." Well I KNOW that. That's why I want to remove them from the Depot!
The option for "Reconcile Offline Work" is grayed out. No idea why.
"Remove from Workspace" returns either "file(s) not in client view." or "no files updated" depending on its mood.
I have other folders in that area that I need to keep but I want to clean up the Depot so ONLY those folders are shown.
If I try "Get Latest Revision" with a force (I figured copy them back then delete while online), it says "11 Files Removed" but changes nothing. I have Refreshed and exited and restarted.
I am using P4V (GUI version)
Your description of the situation as having simply deleted the files offline is not accurate. If the files are not in your client view, it means you have ALSO either:
modified your client view
switched client workspaces
Undo whichever of these you did, and then Reconcile will see the missing files and open them for delete.
Since they are not currently in your client view, there is no association between the deleted files in your workspace and the corresponding depot files. Any time you want Perforce to do anything involving files in your workspace, the client view needs to specify how those files relate to the depot.
(adding more to take into account the comment about the client spec being deleted, and apparently recreated with a different view, which is pretty hard to tell you how to recover from since I don't know anything about the before/after state other than that there are files... somewhere. Unfortunately it's not possible to simply undo a client spec deletion, short of a checkpoint restore, since client specs aren't versioned objects.)
If you deleted your client spec, records of what you previously had synced to your client are deleted along with them (next time just update the Root if your workspace moves), and so Reconcile won't work, even if you recreate the client with the same View.
To be able to delete the files from P4V, you'll need to sync them, but it sounds like you have the additional problem of having re-created your client spec with an incorrect View, so you can't even sync the files yet. Here's what you'll need to do:
Add the depot path to your client view.
Sync the files to your workspace.
Mark for Delete.
Submit.
From the command line syncing is optional, so you could do these steps to delete your client (again), recreate it (with the wide-open default view this time), open the files for delete, and submit:
p4 client -d YOUR_CLIENT
p4 client -o | p4 client -i
p4 delete -v //depot/files/to/delete/...
p4 submit
If you have a spec depot, you may be able to use this to restore your workspace to a point before the view was changed.
More information about working with the spec depot is here:
http://answers.perforce.com/articles/KB/2445
Perforce doesn't recognize the offline deleted files, You have to get latest revision first with 'Fore Operation' Checked.
Now you will see all your deleted files in your depot.
If you still don't see your delete files in depot, then take a backup of the entire folder. Now delete the folder, and do a getlatest with 'Fore Operation' Checked.
Now you will for sure see the deleted files also under the depot.
Now you should do 'Mark for Delete' for the file u wish to delete from depot.

Getting Perforce client workspace handling automated

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).

Resources