p4 edit giving error : file(s) not on client - perforce

On doing p4 edit file1 I am getting err: file(s) not on client.
Tried to edit the file1 from the folder where the file is located and also by giving full file path still got same error.
p4 where gives 3 paths like :
//depot/a/b/c/... //workspace-1/a/b/c/... /local/d/e/f/a/b/c/...
My workspace/client is workspace-1, file is present at path :"/local/d/e/f/a/b/c/"
workspace/client name is correct in .p4config (which is at path : /local/d/e/f/)
On doing p4 client, the P4 client spec file shows correct client name and View is :
//depot/a/b/... //workspace-1/a/b/...
The issue is that p4 is not referring to client but not sure why
.p4config is fine, env P4CLIENT is also set.
Why the client is not getting referred?

Sounds like your client spec is set up correctly, since p4 where is showing the expected thing. The file(s) not on client error means that the file isn't synced.
Do:
p4 sync file1
p4 edit file1

Related

Perforce can't edit file as it says it is already opened, however 'p4 opened' reports otherwise

i'm having this situation
when i try to run p4 edit <file>, it says
- can't edit (already opened on this client)
However, when i ran p4 opened <file> (with the -a and -x option), it says
- - file(s) not opened on this client.
I'm now left in this limbo state.
I can not check out the file,
i can not revert the file,
and i can not check in the file.
How can i fix this? And what happened actually?
First -- double check that all the file paths you stripped out of your question actually match each other. The legitimate way to get this error is if you're trying to edit a depot file that's already open under a different local path on the same client (because you opened it and then changed your client view), and you're trying to reopen the same depot file via the "new" local path while it still has pending changes in the previous location. Make sure you're running p4 opened <file> and p4 revert <file> on the same exact depot path that was returned by the can't edit error.
Once that's eliminated:
This error being thrown when it shouldn't is usually a symptom of an internal database inconsistency in the Perforce server -- the depot file is recorded in the db.locks table as being open on your client, but the corresponding client file isn't in the db.working table.
The easiest way to fix this is for the admin to run p4d -xf 925 on the server root; this is a repair command that looks for this exact inconsistency and should repair it by pruning out unmatched db.locks entries.
p4d -xx will also fix it (this command scans for a set of different inconsistencies and writes a journal patch file to repair them).

Perforce refers to a different root while editing

I have the following perforce client perforce.myClient that contains different directories. When I open a file for edit using /perforce.myClient/p4 edit someFile
it fails with the following message /perforce.myClient/someFile is not under clients root '/my/other/perforce/client'
I did the following to ensure that perforce is picking up the right client
setenv P4CLIENT perforce.myClient
checked to see if the root points to the correct location using p4 client perforce.myClient
How else can I enforce the client?
P4CONFIG files are hugely useful for this. Do this:
p4 set P4CONFIG=.p4config
echo P4CLIENT=perforce.myClient>/perforce.myClient/.p4config
echo P4CLIENT=my.other.perforce.client>/my/other/perforce/client/.p4config
Now your P4CLIENT will change automatically based on your working directory.
http://www.perforce.com/perforce/doc.current/manuals/cmdref/P4CONFIG.html
You should be able to use the global options in your command like
p4 -c myclient edit -c mychangelist //...
Global options appear before the command name.

Perforce - Specify target directory path for sync

Is it possible to specify the folder name where depot needs to be synced ?
I tried syncing the depot to my specified path using following command but it does not work.
p4sync -d "c:\my\path" sync //depot//branch/file
Note : My aim is just to copy the file from depot to my specified location.
Looks like sync is not the command I should be using. Is there any other command or way I can do this ?
sync - gets files from depot to your workspace, which must be already customized. To get files without workspace you need to make some hack with command "print":
p4 print -o filename //path/on/depot/filename
This command (above) gets filename and store it in "filename". Also, you can make some another workaround to get all files from some directory, probably with "p4 -x - command" ( -x stands for xargs in unix-world)

Substituting client path on P4 sync

I have an XML file that refers to some other files. I can use neither relative paths nor variables in this file.
Is it possible to somehow add to the P4 repository a template and some script that will generate that file on the sync? E.g. I can use something trivial like sed to update paths depending on where the P4 client root is.
I really would like to make this transparent so I know that this file is always of proper version and contains actual info.
If you mean you want dynamic root, try putting "null" (no quotes) in the root path of your workspace, and the root of your workspace will be whatever directory you are in.
If you are trying to create a dynamic workspace, you can create a text file of your workspace (p4 client -o > template_worksapce.txt) and use sed on that to create a workspace, then read it in via p4 client -i
Is that what you were looking for?
Try:
p4 info | grep 'Client root'
or:
p4 -ztag client -o | grep Root

P4 changes on a specific folder/file

I am trying to get the last checkin on a particular folder structure on perforce, I know "p4 changes -m1 'filepath" does the job, but the problem is the filepath has to be the depot file-path. What I have on the other hand is the local filepath something like "C:\Android\Version10.2\MyApp\" and not "//depot/Andoid/Version10.2/MyApp".
I tried using commands like "p4 fstat", "p4 where" and "p4 files", but for all of them it works fine with the depot file path, if I give the local file path, it keeps complaining file(s) not on client/no such file(s).
The other issue is I dont have rights to change the p4client on the machine. How do I get this to work?
Basic question then to sum up is being able to get the last change on a folder/file for which I have the local filepath.
Regards
If you're going to run any commands on files those files have to be in the workspace. The problem is probably that p4 on Windows defaults to the machine name as the workspace name if you don't supply one.
So you either have to run set P4CLIENT=<clientname> then run p4 changes -m1 <filename>,
or p4 -c <clientname> changes -m1 <filepath> where <filepath> can be the file on your local file system, so C:\Android\Version10.2\MyApp\ would be acceptable.
Does p4 filelog -m 1 <filename> give you what you want? You can add the -l (lowercase L, not one) switch to get more information.
If you have a local file (as opposed to the depot-path), then you also should have a client-spec. You need to specify this with the -c option:
p4 -c <name-of-client-spec> changes -m1 <filepath>

Resources