Perforce is an enterprise version management system in which you connect to a shared versioning service; users
sync files from the shared repository, called the
depot, and edit them on your workstation in your
client workspace. This chapter assumes that your system administrator has configured your organization's Perforce service. For details about setting up the versioning service, refer to the
Perforce System Administrator's Guide.
Before you start to configure Perforce, ask your Perforce administrator for the proper host and port setting. Also ask whether a workspace has already been configured for your workstation.
A Perforce client workspace is a set of directories on your workstation where you work on file revisions that are managed by Perforce. Each workspace is given a name that identifies the client workspace to the Perforce service. If no workspace name is specified (by setting the
P4CLIENT environment variable) the default workspace name is the name of your workstation. To specify the effective workspace name, set the
P4CLIENT environment variable. You can have multiple workspaces on your machine.
All files within a Perforce client workspace share a root directory, called the client workspace root. The workspace root is the highest-level directory of the workspace under which the managed source files reside.
If you configure multiple workspaces on the same machine, keep workspace locations separate to avoid inadvertently overwriting files. Ensure that client roots are located in different folders and that their workspace views do not map depot files to overlapping locations on your workstation.
The state of your workspace is tracked and managed by Perforce. To avoid conflicts with the file management performed by Perforce applications, do not manually change read-only permission settings on files. Perforce has commands that help you determine whether or not the state of your client workspace corresponds to Perforce's record of that state; see
Working offline for details.
Files in the workspace that you have not put under Perforce control are ignored by Perforce. For example, compiled objects, libraries, executables, and developers' temporary files that are created while developing software but not added to the depot are not affected by Perforce commands.
After defining your client workspace, you can fine-tune the workspace definition. Probably most important, you can restrict the portion of the depot that is visible to you, to prevent you from inadvertently syncing the entire depot. For details, refer to
Refining workspace views.
This guide refers to Perforce settings using environment variables (for example, "set
P4CLIENT"), but you can specify Perforce settings such as port, user, and workspace names using the following methods, listed in order of precedence:
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.
Settings specified on the command line override any settings specified in config files, environment variables, the Windows registry, or OS X system settings. For more details about command-line flags, refer to the discussion of global options in the
Perforce Command Reference.
Config files are text files containing Perforce settings that are in effect for files in and below the directory where the config file resides. Config files are useful if you have multiple client workspaces on the same machine. By specifying the settings in config files, you avoid the inconvenience of changing system settings every time you want to work with a different workspace.
To use config files, you define the P4CONFIG environment variable, specifying a file name (for example,
.p4config). When you issue a command, Perforce searches the current working directory and its parent directories for the specified file and uses the settings it contains (unless the settings are overridden by command-line flags).
Ona sets the P4CONFIG environment variable to
.p4settings. She creates a file called
.p4settings in
/tmp/user/ona containing the following text:
Any work she does on files under /tmp/user/ona is managed by the Perforce service at
ssl:ida:1818 and work she does on files under
/home/ona/p4-ona is managed by the Perforce service at
tcp:warhol:1666.
If you do not specify a protocol in your P4PORT setting,
tcp: (plaintext communication over TCP/IP) is assumed. If the Perforce service has been configured to support SSL, you can encrypt your connection to Perforce by using
ssl: as the desired protocol.
Other protocols (for example, tcp4: to require a plaintext IPv4 connection, or
ssl64: to require an encrypted connection, but to prefer the use of the IPv6 transport instead of IPv4) are available for use in mixed networking environments.
See Connecting over IPv6 networks, and the
System Administrator's Guide, for details.
|
•
|
p4 set setting=value: for the current local user.
|
|
•
|
p4 set -s setting=value: for all users on the local machine. Can be overridden by any registry settings made for the local user. Requires administrative privileges.
|
To see which settings are in effect, use the p4 set command without arguments. For details about the
p4 set command, see the
Perforce Command Reference.
Your client workspace view determines which files in the depot are mapped to your workspace and enables Perforce to construct a one-to-one mapping between individual depot and workspace files. You can map files to have different names and locations in your workspace than they have in the depot, but you cannot map files to multiple locations in the workspace or the depot. By default, the entire depot is mapped to your workspace. You can define a client workspace view to map only files and directories of interest, so that you do not inadvertently sync the entire depot into your workspace. For details, see
Refining workspace views.
Bruno issues the p4 client command and sees a form containing this default client workspace view definition:
Client: bruno_ws Update: 2011/11/29 09:46:53 Access: 2011/03/02 10:28:40 Owner: bruno Root: c:\bruno_ws Options: noallwrite noclobber nocompress unlocked nomodtime normdir SubmitOptions: submitunchanged LineEnd: local View: //depot/... //bruno_ws/...
|
View: //depot/dev/... //bruno_ws/dev/...
|
View: //depot/dev/... //bruno_ws/depot/dev/... //testing/... //bruno_ws/testing/... //archive/... //bruno_ws/archive/...
|
To verify a connection, issue the p4 info command. If
P4PORT is set correctly, information like the following is displayed:
User name: brunoClient name: bruno_ws Client host: workstation_12 Client root: c:\bruno_ws Current directory: c:\bruno_ws Client address: 10.0.0.196 Server address: ssl:example.com:1818
Server root: /usr/depot/p4d Server date: 2012/03/28 15:03:05 -0700 PDT Server uptime: 752:41:33 Server version: P4D/FREEBSD/2012.1/406375 (2012/01/25) Server encryption: encrypted Server license: P4Admin <p4adm> 20 users (expires 2013/01/01) Server license-ip: 10.0.0.2 Case handling: sensitive
|
The Server address: field shows the host to which
p4 connected and also displays the host and port number on which the Perforce service is listening. If
P4PORT is set incorrectly, you receive a message like the following:
Perforce client error: Connect to server failed; check $P4PORT. TCP connect to perforce:1666 failed. perforce: host unknown.
|
If the value you see in the third line of the error message is perforce:1666 (as above),
P4PORT has not been set. Set
P4PORT and try to connect again.
You will be asked to verify the server's fingerprint the first time you attempt to connect to the service. If the fingerprint is accurate, use the
p4 trust command to install the fingerprint into a file (pointed to by the
P4TRUST environment variable) that holds a list of known/trusted Perforce servers and their respective fingerprints. If
P4TRUST is unset, this file is
.p4trust in the user's home directory. For more information, see
SSL-encrypted connections.
Depending on the configuration of your LAN or WAN, your system administrator may recommend different port settings. Your administrator may also recommend that you set the
net.rfc3484 configurable to 1, either from the command line or in a
P4CONFIG file:
Doing so ensures RFC3484-compliant behavior if the protocol value is not explicitly specified; that is, if the client-side configurable
net.rfc3484 is set to
1, and
P4PORT is set to
example.com:1666, or
tcp:example.com:1666, or
ssl:example.com:1666, the user's operating system automatically determines, for any given connection, whether to use IPv4 or IPv6 when communicating with the versioning service.
By default, when you create a client workspace, the entire depot is mapped to your workspace. You can refine this mapping to view only a portion of the depot and to change the correspondence between depot and workspace locations.
To display or modify a workspace view, issue the p4 client command. Perforce displays the client specification form, which lists mappings in the
View: field:
Client: bruno_ws Owner: bruno Description: Created by bruno. Root: C:\bruno_ws Options: noallwrite noclobber nocompress unlocked nomodtime normdir SubmitOptions: submitunchanged View: //depot/... //bruno_ws/...
|
The following sections provide details about specifying the client workspace view. For more information, see the
p4 client command description and the description of views in the
Perforce Command Reference.
Views consist of multiple mappings. Each mapping has two parts.
To determine the location of any workspace file on your workstation, substitute the client workspace root for the workspace name on the client side of the mapping. For example, if the workspace root is
C:\bruno_ws, the file
//depot/dev/main/jam/Jamfile resides in
C:\bruno_ws\dev\main\jam\Jamfile.
Later mappings override earlier ones. In the following example, the second line overrides the first line, mapping the files in
//depot/dev/main/docs/manuals/ up two levels. When files in
//depot/dev/main/docs/manuals/ are synced, they reside in
c:\bruno_ws\docs\.
View: //depot/dev/... //bruno_ws/dev/... //depot/dev/main/docs/... //bruno_ws/docs/...
|
To map groups of files in workspace views, you use Perforce wildcards. Any wildcard used on the depot side of a mapping must be matched with an identical wildcard in the mapping's client side. You can use the following wildcards to specify mappings in your client workspace.
all files in the depot's dev branch are mapped to the corresponding locations in the client workspace. For example, the file
//depot/dev/main/jam/Makefile is mapped to the workspace file
C:\bruno_ws\dev\main\jam\Makefile.
If you are interested only in a subset of the depot files, map that portion. Reducing the scope of the workspace view also ensures that your commands do not inadvertently affect the entire depot. To restrict the workspace view, change the left-hand side of the
View: field to specify the relevant portion of the depot.
View: //depot/dev/main/jam/... //dai-beos-locust/jam/... //depot/www/live/... //dai-beos-locust/www/live/...
|
Views can consist of multiple mappings, which are used to map portions of the depot file tree to different parts of the workspace file tree. If there is a conflict in the mappings, later mappings have precedence over the earlier ones.
View: //depot/... //bruno_ws/... //depot/dev/main/docs/manuals/*.doc //bruno_ws/wordfiles/*.doc
|
View: //depot/... //bruno_ws/... //depot/dev/main/jam/RELNOTES //bruno_ws/dev/main/jam/rnotes.txt
|
Positional specifiers %%0 through
%%9 can be used to rearrange portions of filenames and directories.
View: //depot/allfiles/%%1.%%2 //bruno_ws/filesbytype/%%2/%%1
|
Exclusionary mappings enable you to explicitly exclude files and directories from a workspace. To exclude a file or directory, precede the mapping with a minus sign (
- ). White space is not allowed between the minus sign and the mapping.
View: //depot/dev/main/jam/... //earl-dev-beech/jam/... -//depot/dev/main/jam/....html //earl-dev-beech/jam/....html
|
When you use multiple mappings in a single view, a single file can inadvertently be mapped to two different places in the depot or workspace. When two mappings conflict in this way, the later mapping overrides the earlier mapping.
View: //depot/proj1/... //joe/project/... //depot/proj2/... //joe/project/...
|
The second mapping //depot/proj2/... maps to
//joe/project and conflicts with the first mapping. Because these mappings conflict, the first mapping is ignored; no files in
//depot/proj1 are mapped into the workspace:
//depot/proj1/file.c is not mapped, even if
//depot/proj2/file.c does not exist.
Overlay mappings enable you to map files from more than one depot directory to the same place in a workspace. To overlay the contents of a second directory in your workspace, use a plus sign (
+) in front of the mapping.
View: //depot/proj1/... //joe/project/... +//depot/proj2/... //joe/project/...
|
The overlay mapping +//depot/proj2/... maps to
//joe/project, and overlays the first mapping. Overlay mappings do not conflict. Files (even deleted files) in
//depot/proj2 take precedence over files in
//depot/proj1. If
//depot/proj2/file.c is missing (as opposed to being present, but deleted), then
//depot/proj1/file.c is mapped into the workspace instead.
View: "//depot/Release 2.0/..." //joe/current/... "//depot/Release 1.1/..." "//joe/Patch Release/..." //depot/webstats/2011/... "//joe/2011 Web Stats/..."
|
To specify a workspace that spans multiple Windows drives, use a Root: of
null and specify the drive letters (in lowercase) in the workspace view. For example:
Client: bruno_ws Update: 2011/11/29 09:46:53 Access: 2011/03/02 10:28:40 Owner: bruno Root: null Options: noallwrite noclobber nocompress unlocked nomodtime normdir SubmitOptions: submitunchanged LineEnd: local View: //depot/dev/... "//bruno_ws/c:/Current Release/..." //depot/release/... "//bruno_ws/d:/Prior Releases/..." //depot/www/... //bruno_ws/d:/website/...
|
By default, you can only use a workspace on the machine that is specified by the Host: field. If you want to use the same workspace on multiple machines with different platforms, delete the
Host: entry and set the
AltRoots: field in the client workspace specification. You can specify a maximum of two alternate workspace roots. The locations must be visible from all machines that will be using them, for example through NFS or Samba mounts.
Perforce compares the current working directory against the main Root: first, and then against the two
AltRoots: if specified. The first root to match the current working directory is used. If no roots match, the main root is used.
In the following example, if user bruno's current working directory is located under
/usr/bruno, Perforce uses the UNIX path as his workspace root, rather than
c:\bruno_ws. This approach allows
bruno to use the same client workspace specification for both UNIX and Windows development.
Client: bruno_wsOwner: bruno Description: Created by bruno. Root: c:\bruno_ws AltRoots: /usr/bruno/
|
If you edit text files in the same workspace from different platforms, ensure that the editors and settings you use preserve the line endings. For details about line-endings in cross-platform settings, refer to the
Perforce System Administrator's Guide.
By default, Perforce does not remove empty directories from your workspace. To change this behavior, issue the
p4 client command and in the
Options: field, change the option
normdir to
rmdir.
To change the location of files in your workspace, issue the p4 client command and change either or both of the
Root: and
View: fields. Before changing these settings, ensure that you have no files checked out (by submitting or reverting open files).
|
2.
|
Change the Root: field. (The new client workspace root directory must exist on your workstation before you can retrieve files into it.)
|
|
5.
|
Again, perform a p4 sync. The files in the client workspace are synced to their new locations.
|
|
|
|
|
|
|
Specifies whether unopened files are always writable. By default, Perforce makes unopened files read-only. To avoid inadvertently overwriting changes or causing syncs to fail, specify noallwrite.
If allwrite is set, this option overrides noclobber.
A setting of allwrite leaves unopened files writable by the current user; it does not set filesystem permissions to ensure writability by any user of a multiuser system.
|
|
|
|
Specifies whether p4 sync overwrites writable but unopened workspace files. (By default, Perforce does not overwrite unopened files if they are writable.)
If allwrite is set, clobber is implied; even if present, the noclobber option is ignored.
|
|
|
|
|
|
|
|
Specifies whether other users can use, edit, or delete the client workspace specification. A Perforce administrator can override the lock with the -f (force) flag.
If you lock your client workspace specification, be sure to set a password for the workspace's owner using the p4 passwd command.
|
|
|
|
For files without the +m (modtime) file type modifier, if modtime is set, the modification date (on the local filesystem) of a newly synced file is the datestamp on the file when the file was submitted to the depot. If nomodtime is set, the modification date is the date and time of sync.
For files with the +m (modtime) file type, the modification date (on the local filesystem) of a newly synced file is the datestamp on the file when the file was submitted to the depot, regardless of the setting of modtime or nomodtime on the client.
|
nomodtime
(date and time of sync).
Ignored for files with the +m file type modifier.
|
|
|
Specifies whether p4 sync deletes empty directories in a workspace if all files in the directory have been removed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The share option normalizes mixed line-endings into UNIX line-end format. The share option does not affect files that are synced into a client workspace; however, when files are submitted back to the Perforce service, the share option converts all Windows-style CR/LF line-endings and all Mac-style CR line-endings to the UNIX-style LF, leaving lone LFs untouched.
When you sync your client workspace, line endings are set to LF. If you edit the file on a Windows machine, and your editor inserts CRs before each LF, the extra CRs do not appear in the archive file.
The most common use of the share option is for users of Windows workstations who mount their UNIX home directories as network drives; if you sync files from UNIX, but edit the files on a Windows machine.
|
To delete a workspace, issue the p4 client -d clientname command. Deleting a client workspace removes Perforce's record of the workspace but does not remove files from the workspace or the depot.
For security purposes, your Perforce administrator can configure the Perforce service to require SSL-encrypted connections, user passwords, and to limit the length of time for which your login ticket is valid. The following sections provide details.
If your installation requires SSL, make sure your P4PORT is of the form
ssl:hostname:port. If you attempt to communicate in plaintext with an SSL-enabled Perforce server, the following error message is displayed:
Set P4PORT to
ssl:hostname:port, and attempt to reconnect to the server.
Your administrator can confirm whether the displayed fingerprint is correct or not. If (and only if) the fingerprint is correct, use the
p4 trust command to add it to your
P4TRUST file. If
P4TRUST is unset, this file is assumed to be
.p4trust in your home directory:
If the fingerprint is accurate, enter yes to trust this server. You can also install a fingerprint directly into your trust file from the command line. Run:
p4 trust -p ssl:hostname:port -i fingerprint
where ssl:hostname:port corresponds to your
P4PORT setting, and
fingerprint corresponds to a fingerprint that your administrator has verified.
From this point forward, any SSL connection to ssl:example.com:1818 is trusted, so long as the server at
example.com:1818 continues to report a fingerprint that matches the one recorded in your
P4TRUST file.
This error message indicates that the server's fingerprint has changed from one that you stored in your
P4TRUST file and indicates that the server's SSL credentials have changed.
Although the change to the fingerprint may be legitimate (for example, your administrator controls the length of time for which your server's SSL credentials remain valid, and your server's credentials may have expired), it can also indicate the presence of a security risk.
If your Perforce installation requires plaintext (in order to support older Perforce applications), set
P4PORT to
tcp:hostname:port. If you attempt to use SSL to connect to a service that expects plaintext connections, the following error message is displayed:
Perforce client error: SSL connect to ssl: host: port failed (Connection reset by peer). Remove SSL protocol prefix from P4PORT.
|
Set P4PORT to
tcp:hostname:port (or, if you are using applications at release 2011.1 or earlier, set
P4PORT to
hostname:port), and attempt to reconnect to the service.
Depending on the security level at which your Perforce installation is running, you might need to log in to Perforce before you can run Perforce commands. Without passwords, any user can assume the identity of any other Perforce user by setting
P4USER to a different user name or specifying the
-u flag when you issue a
p4 command. To improve security, use passwords.
Passwords may be up to 1024 characters in length. Your system administrator can configure Perforce to require "strong" passwords, the minimum length of a password, and if you have been assigned a default password, your administrator can further require that you change your password before you first use Perforce.
To reset or remove a password (without knowing the password), Perforce superuser privilege is required. If you need to have your password reset, contact your Perforce administrator. See the
Perforce System Administrator's Guide for details.
|
•
|
Set P4PASSWD to your password, either in the environment or in a config file
|
|
•
|
Specify the -P password flag when you issue p4 commands (for instance, p4 -P mypassword submit)
|
Your Perforce administrator can configure the Perforce service to enforce time limits for users. Perforce uses ticket-based authentication to enforce time limits. Because ticket-based authentication does not rely on environment variables or command-line flags, it is more secure than password-based authentication.
If time limits are in effect at your site, you must issue the p4 login command to obtain a ticket. Enter your password when prompted. If you log in successfully, a ticket is created for you in the ticket file in your home directory, and you are not prompted to log in again until either your ticket expires or you log out by issuing the
p4 logout command.
If your ticket is valid, the length of time remaining is displayed. To extend a ticket's lifespan, use
p4 login while already logged in. Your ticket's lifespan is extended by 1/3 of its initial timeout setting, subject to a maximum of your ticket's initial timeout setting.
By default, your ticket is valid only for the IP address of the machine from which you logged in. If you use Perforce from multiple machines that share a home directory (typical in many UNIX environments), log in with:
Using p4 login -a creates a ticket in your home directory that is valid from all IP addresses, enabling you to remain logged into Perforce from more than one machine.
For more information about the p4 login and
p4 logout commands, see the
Perforce Command Reference.
The Perforce service can be run in Unicode mode to activate support for file names or directory names that contain Unicode characters, and Perforce identifiers (for example, user names) and specifications (for example, changelist descriptions or jobs) that contain Unicode characters.
In Unicode mode, the Perforce service also translates unicode files and metadata to the character set configured on the user's workstation, and verifies that the unicode files and metadata contain valid UTF-8 characters.
To correctly interoperate in Unicode mode, and to ensure that such files are translated correctly by the Perforce service when the files are synced or submitted, you must set
P4CHARSET to the character set that corresponds to the format used on your workstation by the applications that access them, such as text editors or IDEs. These formats are typically listed when you save the file using the menu option.
Values of P4CHARSET that begin with
utf16 or
utf32 further require that you also set
P4COMMANDCHARSET to a non
utf16 or
utf32 character set in which you want server output displayed. "Server output" includes informational and error messages, diff output, and information returned by reporting commands.
For a complete list of valid P4CHARSET values, issue the command
p4 help charset.
To set P4CHARSET for all users on a workstation, you need Windows administrator privileges. Issue the following command:
To set P4CHARSET for the user currently logged in:
p4 set P4CHARSET=
character_set
You can set P4CHARSET from a command shell or in a startup script such as .
kshrc,
.cshrc, or
.profile. To determine the proper value for
P4CHARSET, examine the setting of the
LANG or
LOCALE environment variable. Common settings are as follows:
In general, for a Japanese installation, set P4CHARSET to
eucjp, and for a European installation, set
P4CHARSET to
iso8859-1.
Copyright 2005-2013 Perforce Software.