vscode-perforce icon indicating copy to clipboard operation
vscode-perforce copied to clipboard

Add option to get p4.cfg and client root based on file path

Open farooqu opened this issue 7 years ago • 8 comments

I work in an environment where we symlink files into our perforce stream from another perforce stream. I have realpath set to true, but when trying to edit these files, it tries to edit them in the workspace of the host stream, not in the workspace of the realpath. I have a p4.cfg at the root of all of my workspaces. It would be nice to at least have the option of detecting the client root based on the realpath, rather than from the folder that was opened in vscode.

farooqu avatar Sep 13 '17 16:09 farooqu

have you tried to add a .p4config or .p4settings file at the root of each workspaces ?

stef-levesque avatar Sep 13 '17 17:09 stef-levesque

Yes, I have a p4.cfg and (copied .p4config) at each client root.

Let's say I have stream A at //depot/streamA which has client root ~/perforce/streamA and stream B at //depot/streamB has client root ~/perforce/streamB, with a p4.cfg and .p4config in both client roots specifying the p4client.

I then have vscode opening ~/perforce/streamA/src which contains a symlink to ~/perforce/streamB/src at ~/perforce/streamA/src/lib/streamB. When I try to edit any file from under ~/perforce/streamA/src/lib/streamB I would expect it to edit it in the streamB client, instead I get an error similar to the following: p4 edit "/Users/farooqu/perforce/streamB/src/someFile" ERROR: Path '/Users/farooqu/perforce/streamB/src/someFile' is not under client's root '/Users/farooqu/perforce/streamA'.

This exact behavior works fine in vim with my perforce plugin there.

farooqu avatar Sep 13 '17 18:09 farooqu

Based on this last bugfixing, this should be pretty simple: setting the cwd of p4 (PerforceService.ts ::execCommand) to the real directory of the file be operated on. (note that this would break the p4dir feature without appending the relative-to-local-dir to the -d p4dir)

vrachels avatar Sep 20 '17 19:09 vrachels

I pushed a new version of the extension (2.2.2) Let me know if it resolve your issue.

stef-levesque avatar Oct 17 '17 16:10 stef-levesque

Did not resolve this issue unfortunately.

farooqu avatar Oct 17 '17 17:10 farooqu

Can you try to change your vscode user settings, clear any previous perforce parameter and only keep

"perforce.activationMode": "always"

Then reload your vscode workspace. This should let p4 do the bulk of the work.

stef-levesque avatar Oct 17 '17 18:10 stef-levesque

I don't think this is expected to work given current impl based on what I was looking at. The cwd of p4 would need to be set to each file as it is being executed. New code is required.

vrachels avatar Oct 17 '17 18:10 vrachels

Oh ok, I think I see what you mean...

stef-levesque avatar Oct 17 '17 19:10 stef-levesque