Perforce uses a client/server architecture: you sync files from the server repository, called the
depot, and edit them on your client machine in your
client workspace. This chapter assumes that your system administrator has a Perforce server running. For details about installing the Perforce Server, refer to the
Perforce System Administrator's Guide.
Before you start to configure your client machine, ask your Perforce administrator for the server host and port setting. Also ask whether a workspace has already been configured for your client machine.
A Perforce client workspace is a set of directories on the client machine 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 Server. If no workspace name is specified (by setting the
P4CLIENT environment variable) the default workspace name is the name of the client machine. To specify the effective workspace name, set the
P4CLIENT environment variable. A client machine can contain multiple workspaces.
All files within a Perforce client workspace share a root directory, called the client root. The client 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 client views do not map depot files to overlapping locations on the client machine.
The state of your client workspace is tracked and managed by the Perforce server. To avoid conflicts with the file management that is performed by the server, do not manually change read-only permission settings on files. You can verify that the state of the client workspace corresponds to the server's record of that state. For details, refer to Technote 2 on the Perforce web site:
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 client views.
This guide refers to Perforce settings using environment variables (for example, "set
P4CLIENT"), but you can specify Perforce settings such as server port, user, and workspace names using the following methods, listed in order of precedence:
To configure your client machine to connect to a Perforce server, you specify the name of the host where the server is running, and the port on which the server is listening. The default server host is
perforce and default server port is 1666. If the server is running on your client machine, specify
localhost as the host name. If the server is running on port 1666, you can omit the port specification.
Server settings specified on the command line override any settings specified in config files, environment variables, or the Windows registry. 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 server at
ida:1818 and work she does on files under
/home/ona/p4-ona is managed by the Perforce server at
warhol:1666.
•
|
p4 set setting=value: for the current Windows login.
|
•
|
p4 set -s setting=value: for all users on the local machine. Overrides any registry settings made for the local user. Requires Perforce admin privilege.
|
To see which settings are in effect, type the p4 set command. For details about the
p4 set command, see the
Perforce Command Reference.
Your client view determines which files in the depot are mapped to a client workspace and enables the server 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 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 client views.
Bruno issues the p4 client command and sees a form containing this default client view definition:
Client: bruno_ws Update: 2004/11/29 09:46:53 Access: 2005/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: 127.0.0.1:28 Server address: localhost:1667 Server root: /usr/depot/p4d Server date: 2008/06/28 15:03:05 -0700 PDT Server uptime: 752:41:23 Server version: P4D/FREEBSD4/2008.1/156375 (2008/05/25) Proxy version: P4P/SOLARIS26/2008.1/156884 (2008/05/25) Server license: P4 Admin <p4adm> 20 users (expires 2009/01/01) Server license-ip: 10.0.0.2
|
The Server address: field shows the Perforce server to which
p4 connected and also displays the host and port number on which the Perforce server 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. If the value is anything else,
P4PORT is set incorrectly.
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 client 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 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 client file on the host machine, substitute the client root for the client name on the client side of the mapping. For example, if the client root is
C:\bruno_ws, the file
//depot/dev/main/jam/Jamfile resides in the workspace as
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 client 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 client view mappings.
all files in the depot's dev branch are mapped to the corresponding locations in the workspace. For example, the file
//depot/dev/main/jam/Makefile is mapped to the client workspace file
C:\bruno_ws\dev\main\jam\Makefile.
The mappings in client workspace views always refer to the locations of files and directories in the depot; you cannot refer to specific revisions of a file in a client view.
If you are interested only in a subset of the depot files, map that portion. Reducing the scope of the client view also ensures that your commands do not inadvertently affect the entire depot. To restrict the client 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 client 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 client workspace. To overlay the contents of a second directory in your client 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/2006/... "//joe/2006 Web Stats/..."
|
To specify a Perforce client workspace that spans multiple Windows drives, use a Root: of
null and specify the drive letters (in lowercase) in the client view. For example:
Client: bruno_ws Update: 2004/11/29 09:46:53 Access: 2005/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 client workspace on multiple machines with different platforms, delete the
Host: entry and set the
AltRoots: field in the client specification. You can specify a maximum of two alternate client 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 client 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.
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, the Perforce server makes unopened files read-only. To avoid inadvertently overwriting changes or causing syncs to fail, specify noallwrite.
|
|
|
Specifies whether p4 sync overwrites writable but unopened workspace files. (By default, Perforce does not overwrite unopened files if they are writable.)
|
|
|
|
|
|
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, regardless of Perforce client version.
|
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 Server, 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 client workspace specification, issue the p4 client -d clientname command. Deleting a client specification removes the Perforce server'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 server to require passwords and to limit the length of time for which your login ticket is valid. The following sections provide details.
Depending on the security level at which your Perforce server 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.
Your system administrator can configure your Perforce server to require "strong" passwords. A password is considered strong if it is at least eight characters long and contains at least two of the following:
For example, a1b2c3d4,
A1B2C3D4,
aBcDeFgH are strong passwords.
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 server 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 for your server, 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.
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 server 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 server also translates unicode files and metadata to the character set configured for the client machine, and verifies that the unicode files and metadata contain valid UTF-8 characters.
To correctly interoperate with Unicode-mode servers, and to ensure that such files are translated correctly by the Perforce server when the files are synced or submitted, you must set
P4CHARSET to the character set that corresponds to the format used on your client machine 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.
To set P4CHARSET for all users on a workstation, you need Perforce 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-2009 Perforce Software.