在 p4win gui 客户端中找到的“切换端口客户端用户”的命令行等效项是什么?
我已经在一个端口下登录,但现在我试图连接到同一服务器上的不同端口,以便访问单独的源代码控制文件库。我认为这将涉及使用:
p4 login
但是,阅读“登录”的“帮助”不会显示指定端口号的选项。用户名和客户端名称将保持不变,但只需要更改端口号。
在 p4win gui 客户端中找到的“切换端口客户端用户”的命令行等效项是什么?
我已经在一个端口下登录,但现在我试图连接到同一服务器上的不同端口,以便访问单独的源代码控制文件库。我认为这将涉及使用:
p4 login
但是,阅读“登录”的“帮助”不会显示指定端口号的选项。用户名和客户端名称将保持不变,但只需要更改端口号。
P4PORT 配置变量存储要连接的 Perforce 服务器名称和端口号。您可以将此值设置为环境变量,或者,如果您使用的是 Windows,则可以在注册表中使用“p4 set”:
p4 set P4PORT=perforce:1669
要查看 P4PORT 的当前值是多少:
> p4 set P4PORT
P4PORT=perforce:1669
如果您想对任何 P4 命令通用地执行此操作,则可以通过“p4 help usage”找到通用形式。
简而言之,
p4 -p <your port> login
会做你要求的。从使用帮助中可以看出,您可以从命令行指定大多数内容,例如客户端规范、用户名、密码等。
例如:
p4 set P4PORT=1666
从帮助:
C:\> p4 help environment
Environment variables used by Perforce:
Variable Defines For more information see
-------- ------- ------------------------
P4AUDIT name of server audit file p4d -h
P4CHARSET client's local character set p4 help charset
P4COMMANDCHARSET client's local character set for
command line operations p4 help charset
P4CLIENT name of client workspace p4 help client
p4 help usage
P4CONFIG name of configuration file Command Reference Manual
P4DIFF diff program to use on client p4 help diff
P4DIFFUNICODE diff program to use on client p4 help diff
P4EDITOR editor invoked by p4 commands p4 help change, etc
P4HOST name of host computer p4 help client
p4 help usage
P4JOURNAL name of server journal file p4d -h
P4LANGUAGE language for text messages p4 help usage
P4LOG name of server log file p4d -h
P4MERGE merge program to use on client p4 help resolve
P4MERGEUNICODE merge program to use on client p4 help resolve
P4PAGER pager for 'p4 resolve' output p4 help resolve
P4PASSWD user password passed to server p4 help passwd
P4PORT port client connects to p4 help info
or server listens on p4d -h
P4ROOT server root directory p4d -h
P4TARGET target server for proxy Command Reference Manual
P4TICKETS location of tickets file Command Reference Manual
P4USER user name p4 help usage
PWD current working directory p4 help usage
TMP, TEMP directory for temporary files Command Reference Manual
See 'p4 help set' for details specific to Windows. The syntax for
setting an environment variable depends on the OS/shell. Note that many
shells allow the setting of shell variables separate from environment
variables - Perforce cannot see the shell variable, only the environment
variable.
If you are a typical user then the only variables of interest are
$P4CLIENT, $P4PORT and $P4PASSWD.
C:\> p4 help set
set -- Set variables in the registry (Windows only)
p4 set [ -s -S service ] [ var=[value] ]
'p4 set' sets the registry variables used by Perforce on Windows
platforms. Normally, the variable 'var' is set to 'value'.
If 'value' is missing, the variable 'var' is unset. Without
any arguments at all, 'p4 set' list variable settings.
The -s flag causes 'p4 set' to set variables for the whole system
rather than for the user. You must have NT administrator powers
to use this.
The -S service flag causes 'p4 set' to set variables for the named
service. You must have NT administrator powers to use this.
Currently, registry variable entries may be overridden by environment
variables and (in some cases) flags on the command line.
See 'p4 help environment' for a list of environment/registry variables.
您可以使用配置文件为每个项目设置 Perforce 连接的端口。
首先,创建一个文本文件,其中包含您要为项目设置的 Perforce 配置变量。例如,要设置 P4PORT 的值,文件的内容将如下所示:
P4PORT=hostname:1234
将文件命名为.p4config之类的描述性文件,并将其放在项目文件夹的根目录中。为您的每个项目执行此操作,并根据需要更改变量。 使用相同的文件名。
然后,将 P4CONFIG 的值设置为配置文件的名称,例如
p4 set P4CONFIG=.p4config
这将使 Perforce 在当前目录或任何父目录中的该名称的文件中查找配置值,因此您不必在每次切换项目时手动更改配置变量。