How to set defaults for perforce client specs

p4 set client root
p4 client template
p4client
p4config
p4 workspace
perforce update client
p4 sync
perforce must create client

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.

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:

Client: my_template_client
...
Options:    noallwrite noclobber nocompress unlocked nomodtime rmdir

SubmitOptions:  revertunchanged
...

Then you just specify that the dummy client should be used as a template when creating new clients:

p4 client -t my_template_client my_new_client_1

Configuring P4 // P4 User's Guide, If no workspace name is specified (by setting the P4CLIENT environment variable) the default No files are synced when you create a client specification. To change your current client workspace: Click the Settings tab, enter the name of the client spec that you want to change to, and click Save, or Click the Clients tab, click on the client name that you want to change to, and select the Switch to client link at the bottom of the page. Click the Edit current client link at the top of the page to modify the current client spec. If you are a new Perforce user just starting out, the only client spec fields that you have to edit are Root and View

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

p4 client // P4 Command Reference, Create or edit a client workspace specification and its view. the client name defaults to the P4CLIENT environment variable if set, or to the current host name. To configure your workstation to connect to the Perforce service, you specify the name of the host where the service is running, and the port on which it is listening. The default host is perforce and default port is 1666. If the service is running on your own machine, specify localhost as the host name. If the service is running on port 1666, you can omit the port specification.

P4Web User Guide - Editing Client Specs, To edit a client spec, it must be set as your current client workspace (check at the top of If you're creating your first workspace, you can leave the default values  To use aronTest as a template for the new client cli, you'd simply type p4 client -t aronTest cli instead of p4 client cli. If your Perforce server is running release 2014.1 or later, you can set the 'template.client' configurable on the server to specify a default template client to be used when the -t argument is omitted.

Managing Workspace Specifications, On the Basic tab, accept or change the default workspace name and root. Map the icon and enter your view specification using Perforce client view syntax. The p4 client command puts the client spec into a temporary file and invokes the editor configured by the environment variable P4EDITOR. For new workspaces, the client name defaults to the P4CLIENT environment variable if set, or to the current host name. Saving the file creates or modifies the client spec.

p4 client, Use the p4 client command to create or edit a client workspace specification. the client name defaults to the P4CLIENT environment variable if set, or to the  The p4 client command puts the client spec into a temporary file and invokes the editor configured by the environment variable P4EDITOR. For new workspaces, the client name defaults to the P4CLIENT environment variable if set, or to the current host name. Saving the file creates or modifies the client spec.

p4 client, Create or edit a client workspace specification and its view. the client name defaults to the P4CLIENT environment variable if set, or to the current host name. For the Windows service, which defaults to the name Perforce, instruct p4s.exe to wait 2700 seconds before starting to send keepalives. You must have administrative privileges to do this. p4 set P4EDITOR="C:\File Editor\editor.exe" On Windows, for the current local user, set the path for the default text editor.

Comments
  • Thanks, I suspected I'd have to resort to templates. I'm assuming your command line above is missing the "client" from the end ;)
  • Oops, sorry. That should have been 'p4 client -t my_template_client my_new_client_1'
  • Note that my first line said "unless you're the Perforce system administrator". Your examples are from the Perforce System Administrator's Guide. Triggers may only be defined by Perforce superusers.
  • Thanks for the info - I'm probably not going to have permission to set triggers, but I'll give that a go. I think what you have put is here is valuable to some, so maybe I could split this into two questions - one for strictly basic user and one for those with more complete access.