stef-levesque / vscode-perforce

Perforce basic commands for Visual Studio Code
MIT License
74 stars 103 forks source link

vscode-perforce fails when using a "personal (local) server" #169

Open jdputsch opened 5 years ago

jdputsch commented 5 years ago

When using a "personal (local) server", vscode-perforce generates incorrect "p4" command lines.

To reproduce: Personal servers may be created via one of these methods:

In workspace using a personal server, the .p4config file contains a P4PORT entry that looks like these: Windows: P4PORT=rsh:p4d.exe -i -J off -r "$configdir\.p4root" Linux: P4PORT=rsh:/bin/sh -c "umask 077 && exec p4d -i -J off -r '$configdir/.p4root'" OSX: P4PORT=rsh:/bin/sh -c "umask 077 && exec p4d -i -J off -r '$configdir/.p4root'"

Actual Results This leads the Perforce integrate to run P4 commands that look like this:

"p4" -u jeff.putsch -c jeff.putsch-dvcs-1566707823 -p rsh:/bin/sh -c "umask 077 && exec p4d -i -J off -r '$configdir/.p4root'" -d /home/putsch/src/Maxim/mdx/mipi/ edit "/home/putsch/src/Maxim/mdx/mipi/README.rst"

Which does not provide a valid P4 command:

  1. The quoting of the P4PORT is wrong.
  2. The value of $configdir is not expanded.

Expected Results:

A valid P4 command that works in this environment.

One idea would be to add "P4CONFIG" to the environment, then not use the "-p " option if P4PORT starts with "rsh:".

Jeff.

ulfwin commented 4 years ago

I'm also suffering from this issue on my windows computer. My current workaround is changing the .p4config file by expanding the $configdir to the actual directory, and placing quotes around the p4d command, like this: P4PORT=rsh:"p4d.exe -i -J off -r h:\perforce\ulf_personal_server\.p4root"

The problem (except having to manually fiddle) is that the p4 command does not compute this, so any manual commands i'd like to run will not work.

mjcrouch commented 4 years ago

Hi @ulfwin @jdputsch I've just pushed an update to my fork that partially resolves this.

Specifically, I've changed how it runs commands so everything should be correctly escaped, so your .p4config file doesn't need random quotes in it (I haven't tested on windows so my command is slightly different, but it should be cross platform)

It does not fix the variable expansion, so you still need to change the default generated .p4config file to replace $configdir with the real path.*

I tested it by changing the P4PORT as described, and ensuring perforce.port vscode config setting was not defined, and it works for me

* ultimately I would like to change the activation so it doesn't explicitly read the p4 config file, but uses perforce's own logic to get the correct client details, which would expand the variables automatically, but it's quite a big task

ulfwin commented 4 years ago

Tired and working on Windows! Thanks a lot @mjcrouch !

Indeed expanding the variables would be nice, but the biggest problem of having to change back and fourth is taken care of with this work around.