如何设置 perforce 客户端规范的默认值
我正在尝试了解如何更改默认的客户端规范选项和提交选项集。
set P4CLIENT=my_new_client_1
p4 client
给我以下规范默认规范:
Client: my_new_client_1
...
Options: noallwrite noclobber nocompress unlocked nomodtime normdir
SubmitOptions: submitunchanged
...
现在在我的机器上我想始终使用 revertunchanged
、rmdir
例如,但似乎我需要记住每次都手动设置它我创建一个新客户端。
有什么办法可以实现这一点吗? p4 set 似乎只影响可以通过环境变量设置的东西。
I'm trying to discover how to change the default set of Client Spec options and submit-options.
set P4CLIENT=my_new_client_1
p4 client
Gives me the following spec default-spec:
Client: my_new_client_1
...
Options: noallwrite noclobber nocompress unlocked nomodtime normdir
SubmitOptions: submitunchanged
...
Now on my machine i want to always use revertunchanged
, rmdir
for example, but it seems like I need remember to manually set this everytime I create a new client.
Is there any way to achieve this? p4 set seems to only affect the things that can be set by environment variables.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您无法更改默认的客户端规范模板(除非您是 Perforce 系统管理员),但您可以设置和使用自己的模板。您首先要创建一个虚拟客户端,其客户端规范具有您想要的值:
然后您只需指定在创建新客户端时应将虚拟客户端用作模板:
You can't change the default client spec template (unless you're the Perforce system administrator) but you can set up and use your own template. You would first create a dummy client with a client spec that has the values that you want:
Then you just specify that the dummy client should be used as a template when creating new clients:
这里的第一个响应是不正确的:
您可以使用触发器在 Perforce 中创建默认的 clientspec。
本质上,您创建一个在服务器上运行的脚本,并在有人在表单客户端上执行表单输出时运行。该脚本必须检查 clientspec 是否已存在,然后如果不存在则替换为合理的“默认值”(如果它是新的 clientspec)。
请注意,这工作得很好,甚至在 P4 SysAdmin Guide 中也有(您正在寻找的确切示例就在那里!),但调试起来可能有点困难,因为触发器在服务器上运行,而不是在客户端上运行!
手动的:
http://www.perforce.com/perforce/r10。 1/manuals/p4sag/06_scripting.html
具体案例示例:
http://www.perforce.com/perforce/ r10.1/manuals/p4sag/06_scripting.html#1057213
The first response here was incorrect:
You CAN create a default clientspec in Perforce using triggers.
Essentially, you create a script that runs on the server and runs whenever someone does a form-out on the form client. This script would have to check to see if the clientspec already exists, and then substitute a sensible "default" if it doesn't (if it's a new clientspec).
Note that this works fine and well, and it's even in the P4 SysAdmin Guide (the exact example you're looking for is there!) but it can be a bit difficult to debug, as triggers run on the SERVER, not on the client!
Manual:
http://www.perforce.com/perforce/r10.1/manuals/p4sag/06_scripting.html
Specific Case Example:
http://www.perforce.com/perforce/r10.1/manuals/p4sag/06_scripting.html#1057213
Perforce Server 部署包 (SDP) 是一个参考实现,其中包含操作 Perforce Helix Core 服务器的最佳实践,其中包含正是用于此目的的示例触发器。请参阅:
使用
p4 client -t
非常有用,并且是普通用户可以执行的操作,并且还具有等效的 P4V(图形用户界面)。只有 Perforce 超级用户才能搞乱触发器。超级用户还需要注意另一个技巧:如果用户没有使用
-t
指定客户端规范,他们可以指定一个客户端规范作为默认值。这可以通过设置可配置的 template.client 来完成。请参阅:https://www.perforce。 com/manuals/cmdref/Content/CmdRef/configurables.configurables.html#template.client另一项建议:我建议将默认值从
submitunchanged
更改为leaveunchanged
而不是revertunchanged
(如上面的示例触发器中所示)。使用leaveunchanged
更好,因为如果您仍希望签出文件,使用leaveunchanged
而不是revertunchanged
可以让您不必导航到该文件再次检查一下。这是一件小事,但最好保持不变。如果您确实想恢复未修改的文件,恢复比再次签出稍微容易一些,这可能需要更多的导航或输入。The Perforce Server Deployment Package (SDP), a reference implementation with best practices for operating a Perforce Helix Core server, includes sample triggers for exactly this purpose. See:
Using the
p4 client -t <template_client>
is useful and is something a regular user can do, and has a P4V (graphical user interface) equivalent as well. Only Perforce super users can mess with triggers.There is one other trick for a super user to be aware of: They can designate a client spec to be used as a default if the user doesn't specify one with
-t <template_client>
. That can be done by setting the configurable template.client. See: https://www.perforce.com/manuals/cmdref/Content/CmdRef/configurables.configurables.html#template.clientOne other suggestion: I suggest changing the default from
submitunchanged
toleaveunchanged
rather thanrevertunchanged
(as in the sample triggers above). Usingleaveunchanged
is better because, if you still want the file checked out, usingleaveunchanged
rather thanrevertunchanged
saves you from having to navigate to the file to check it out again. It's a small thing, but optimal to go with leaveunchanged. If you do want to revert the unmodified file, it's slightly easier to revert than to checkout again, which might require more navigating or typing.