SimpsonGSD / P4EditVS

Simple, lightweight Visual Studio plugin to run various Perforce commands on files, such as checkout and revert. Includes optional auto-checkout feature.
https://marketplace.visualstudio.com/items?itemName=ScottSimpson.p4editvs
MIT License
32 stars 8 forks source link

Open in P4V command does not use .p4config when Use Environment is selected #22

Open SimpsonGSD opened 2 years ago

SimpsonGSD commented 2 years ago

It's being reported that even though Use Environment is selected in one solution it is not using the .p4config file to get the correct P4 environment.

  • I tried a different solution, and it also crashed. Got an error message from perforce in the process: _Path 'e:\perforce\new_solution\new_file.cpp/...' is not under client's root 'D:\dev\perforce\originalsolution'. Both solutions have a .p4config set up, and Use Environment is true, so I guess the environment variables are pointing at original_solution or something? Shouldn't it use .p4config though?

Originally posted by @Malrog in https://github.com/SimpsonGSD/P4EditVS/issues/21#issuecomment-1054410103

Malrog commented 2 years ago

I suspect this was an issue with how I had p4v configured. In p4v Edit>Preferences I had the application launch set to "Restore all previously opened connections." So when the previous connections were to a different workspace (and sometimes even different server), this resulted in the issue reported above. Altering this setting to "Show connection dialog" allows me to pick the correct server + workspace, and that obviously works. Similarly, altering this setting to "Open the connection specified by your Perforce environment settings" also works - automatically opening to the correct server + workspace.

To fix this when Use Environment is selected you would probably need to extract the necessary p4 environment parameters to pass -p, -u and -c to your p4v call, which would then presumably override the setting in p4v.

SimpsonGSD commented 2 years ago

Hmm I would have thought that would only affect P4V (I could be wrong). Checkout commands, etc, use p4.exe and invokes the process from the working directory of the file that's being checked out. As long as p4config file is in that directory of one of the parent directories it should pick up the correct env vars.

Did you test checkout? Where is your p4 config file located relative to the file being checked out?

Malrog commented 2 years ago

It's just the "Open in Perforce" command (which runs p4v.exe) that is affected by this. Sorry if that wasn't clear. Everything else works fine.

SimpsonGSD commented 2 years ago

Ok that's good to know. I've updated the title to reflect it's for that command only.

One option is to use p4 set and get the variables to pass to P4V, as long as p4 set does not query the server and is a local operation only.