How to rename the file which is in perforce depot - perforce

what is the process to rename the files in depot without getting any conflicts?
Is there any way either in p4 or command line?

Yes, but the method depends on the version of Perforce you're running. Here's how to do it from the command line (this is copied from the output of "p4 help rename").
In release 2009.1 and higher, you can use 'p4 move' to move or
rename files. Perforce clients prior to release 2009.1 do not
support 'p4 move'. However, files in older clients can be
renamed by branching one file to another and deleting the
original file. For example:
p4 integrate fromFile toFile
p4 delete fromFile
p4 submit
For further information, see the help for the individual commands.
Note: Files renamed in this way are treated as branched files
rather than moved files in subsequent operations.

Related

How can I compare a file in a perforce workarea to it's unaltered counterpart in the depot?

Server version: P4D/LINUX26X86_64/2018.2/1975995 (2020/06/25)
Proxy version: P4P/LINUX26X86_64/2018.2/1975995 (2020/06/25)
Broker version: P4BROKER/LINUX26X86_64/2010.2/279478
After I sync a perforce workarea to head, I 'p4 edit' a file, then manually edit the file in my workarea using my favorite text editor. Over time, other users submit changes, so I am no longer synched to the head. And I may save and re-edit the file in my workarea. Now, I want to compare my edited version of the file to the version that I synched to (which is no longer head).
I'm OK with doing a 'p4 print' of the file (with, I'm assuming, a version specifier) in the P4 depot, then comparing my edited file with that outside of p4 commands. Using one of the p4 diff commands isn't really what I want to do because the file is an xml file for which I wrote a perl script which will compare content in an order agnostic way.
I think the missing piece here is getting a handle on the P4 version of the file that my WA is synched to so that I can p4 print it out and then compare. Not sure how to do that. I'm also open to other suggestions, but remember the comparison will eventually be done by my perl script which does simple file open commands.
Set P4DIFF to point to your perl script (which needs to take the two local files as arguments) and run p4 diff. The p4 diff command does all the work of "printing" the depot file to a local temp file, invoking the diff tool (specified by P4DIFF), and cleaning up the temp file.

Perforce Revision of Files

Cannot over write files on Perforce
A file with errors was uploaded to Perforce, we are now trying to overwrite that file and update it with the correct file. Unfortunately many of the character assets will not resolve showing a padlock, yellow triangle and a red tick.
The error messages are telling us that we can't overwrite the files unless we have an up to date version. The most up to date version is the one with errors! How do we unlock and resolve these assets
Get the latest revisions. You can browse submitted changelists and identify a changelist that introduces the error. You can back out that changelist which will create changelist on which the files will be edited that way that their content will be reverted. Submit that changelist.
I'm not sure which UI you're using (P4V? P4Win? One of the IDE plugins?), so I'll just give the command line instructions:
p4 sync FILE
p4 resolve -ay
The sync tells Perforce that you want to sync up with the latest depot revision of the file. Since the file is open for edit, this won't actually modify the file on disk, and will instead set up a resolve operation.
The resolve -ay (accept yours) tells Perforce that you want to ignore the latest revision from the depot, and keep your workspace revision instead, which is the one that you want to submit.
Now the "yellow triangle" should go away and you'll be able to submit. (Unless that "padlock" belongs to someone else...)

How to only receive get file changed by revision In perforce P4

In P4, I only want to pull file changed my client workspace from server. But When I use "p4 sync", this command get all files from server. So, How to get files changed from list revision ? with the files were existed on local and not changed, the command P4 sync do not need sync. My command is here:
p4 sync -f //depot/...#Revision
If you want to restore a file you deleted with p4 delete file, use p4 revert file, not p4 sync. p4 sync is for getting the changes that other people made to the files, not for altering the changes that you made.
There are three different reasons that the files in your workspace might differ from the current head revision in the depot:
A new revision has been submitted to the depot since the last time you synced.
You have opened the files (e.g. with p4 edit) and made changes to them that are not yet submitted.
You have modified the read-only synced files in your workspace without opening them.
(You don't say in your question which of these is the case, which is why you've gotten a couple of different answers that are based on different assumptions about your workspace state -- I'm guessing it's #3, personally, but I'll give the answer for each one so you can understand how it's "supposed" to work vs what's actually going on here.)
In case 1, a normal p4 sync command will update only the files with new revisions. If the revision you previously synced is the same as the head revision, p4 sync won't update it. This makes p4 sync very fast -- you can have a million files in your workspace, and if only one of them has changed since you last sync, only that one file is affected.
In case 2, no p4 sync command will update the files, in the interest of preserving your open changes. To submit your changes to the depot, use p4 submit; to discard them, use p4 revert. Again, only the open files are affected by these commands, so a revert operation affecting only a few files isn't slowed down by however many other files are in your workspace.
In case 3, your workspace is in an inconsistent state -- Perforce's standard workflow is that any time you modify a local file you should "open" it so that the server can track your local work (and optimize operations like sync, submit, etc, as well as alert other users who open those files simultaneously to potential conflicts). If you modify a file locally without modifying it, commands like sync will no longer work as well because the state of your client is not known to the server.
You can recover from an inconsistent state by using the p4 reconcile command (which will open all the inconsistent files so that you can either submit or revert them), or the p4 clean command (which irrevocably discards the inconsistent local changes, as if you'd done p4 reconcile immediately followed by p4 revert). These commands are significantly slower than a normal sync operation since they need to scan the entire workspace rather than only the changed files, but they are still significantly faster than a sync -f since only the changed files are actually re-transferred.

Accidental mark for delete - entire depot and reverting - perforce ..How to remove that tag(Mark for delete) from all files

Whole workspace files marked as delete in local also and depot also.
Depot contains thousands of file ..While reverting file options P4 get's hanged..
Any Solution for this ...help me...
Thanks in advance.
When P4V hangs on these mass commands, I prefer using the command-line. In this case, p4 revert //depot/path/to/the/workspace/....
Make sure you don't actually revert things you want to keep though.

Perforce unshelve with merge from command line

How can I instruct perforce command line to merge files instead of overwriting them when unshelving?
The use case is the following: I have a shelf that changes "my_file". On a "clean" (p4 revert ...) owner of the shelf I update to the latest version. I then want to unshelve but the action should merge any potential conflicts instead of overwriting them. Is this possible via command line?
This is the command line version of How can I instruct Perforce to merge instead of overwrite or revert when unshelving a file?.
If your workspace is "clean", there will be no conflicts. The file will be unshelved at the originally shelved version; if you sync to a different version, that will automatically schedule a resolve.
If your local file is open, unshelving will schedule a resolve automatically (at least with current versions; older versions would refuse to unshelve over open changes).
If your local file is modified but not open, you might get the overwriting behavior you describe. Don't do that. :) Use "p4 reconcile" prior to unshelving to make sure that modified files are properly opened, or "p4 clean" to discard those modifications.

Resources