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

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

Related

In Perforce, how can I check in a file previously checked out on another machine/workspace?

I hope I'm not asking a question that's already been answered, but I can't seem to find one that fits my situation.
Scenario: Using P4V gui (2011 version), with no access to P4 command line, on Windows 7.
The setup: A user creates a workspace in Perforce from Machine A, pointing that workspace to a shared network drive, and checks out a file for editing.
Machine A then dies before the user can check in the file. The user is then assigned Machine B, for which he must create a new workspace (which is also pointed at the same shared network drive).
The problem: The problem we're having is that even though the workspace from the dead Machine A and from the new Machine B both point to the same location, Perforce considers them to be different workspaces and prevents the user from checking in/submitting the previously checked out file.
Any suggestions on how to check in this stranded file would be greatly appreciated. Thank you very much!
To be nice and clean, I'd suggest this:
Make a backup copy of the file as it exists on the shared network drive.
Connect to the depot from Workspace A (can be done from Machine B if the workspace isn't bound to Machine A).
Revert the file - this will overwrite the file on the drive with the version in the depot (aren't you glad you made a copy first?).
Switch to Workspace B.
Check out the file.
Copy the backup version over the file on the shared network drive.
Check in the file.
...and if you're not planning on using Workspace A anymore, I'd suggest deleting it.
Have you tried clearing out the Host field? For example, see 'Using the same workspace from different machines':
http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.configuration.html#d0e1720
As an update from my comment response, if you need to change ownership of a changelist, the steps are documented here:
http://answers.perforce.com/articles/KB_Article/Changing-the-Owner-of-a-Pending-Changelist

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.

Perforce Get Latest Revision doesn't get checked-out files?

When using p4v to sync a project onto a 2nd machine I was surprised to see that files I had checked out on my primary machine were not included in the "Get Revision" (Get Latest Revision and Force options selected).
This seems like an elemental thing to get working but I can't find how to force this other than perhaps tagging the source tree and getting that, which I don't want to do if I don't have to. . .
This is an elemental thing. Syncing on one computer is in no way influenced by what you have open for edit on another. Syncing retrieves all those files regardless of who has them checked out, unless you have confused the server by messing with files outside the Perforce client. However, you said you used the -f option, which would solve that problem.
Are you sure you don't have those missing files open for add and not for edit?

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

What's the best way to move to a new Perforce server?

My home Perforce server died. I set up a new one.
The project I set it up to support died in the planning phase. The contents of the depot at that point were some prototype code and we never got to setting up a disaster recovery plan.
The dev machines still have the existing code on them. As much as possible, I'd like the change of servers to be transparent to the developers--use the same depositories and the same directories, just change the name of the server to connect to and get back to work.
What do I need to do in order to make this happen?
I assume you don't have access to the perforce depot files from your dead server? I assume you know that you will lose all your history.
If that's the case all you need to do is setup the new server, create a user / client with the same root clientspec path as your original clientspec was using on your dev machine and checkin all the files into perforce. Pretty simple really...
You may need to rebind is SCM binding that you may have in tools like Visual Studio but that's about it.
What Shane suggested will populate the depot with one person's version of the files. But if you have another user who also has a copy then you'll need a couple of extra steps.
Firstly, just set one machine up as suggested by Shane.
You now need to get the second user set up. If you are confident that the version of the code user 2 has exactly matches what you put in the new server, then just create a client spec (probably same name as used before), and then sync using the "Force" flag. This will overwrite all the files on user 2's machine, and - more importantly - ensure Perforce knows which versions you really have.
However, if you are in any doubt as to any differences in code, then do not do the initial sync from the second user's machine. Instead, set up the client spec, then use the "Reconcile offline work" option - from P4V select the workspace, then it's a right click option. Then just walk through the subsequent dialog to sort out what you need.
Finally, if you want a very quick & dirty backup system for your server, I've posted some notes on my blog here - should take you just a couple of minutes to set up.

Resources