Perforce Command Reference:   [Index] [Prev] [Next]


Views

Synopsis

There are three types of views: client views, branch views, and label views. Client views map files in the depot to files in the client workspace, branch views map files in the depot to other parts of the depot, and label views associate groups of files in the depot with a single label.

Each type of view consists of lines which map files from the depot into the appropriate namespace. For client and branch views, the mappings consist of two file specifications. The left side of the mapping always refers to the depot namespace, and the right side of the mapping refers to the client workspace or depot namespace. For label views, only the left side (the depot namespace) of the mapping need be provided - the files thus specified are then associated with the desired label.

All views construct a one-to-one mapping between files in the depot and the files in the client workspace, branch, or label. If more than one mapping line refers to the same file(s), the earlier mapping will be overridden. Mappings beginning with - will specifically exclude any files that match that mapping. If multiple mappings in a single view lead to files which fail to map the same way in both directions, the files will be ignored.

File specifications within mappings are provided in the usual Perforce syntax, beginning with //, followed by the depot, client, or label name, and followed by the actual file name(s) within the depot or client. File specifications within mappings may contain the usual Perforce wildcards of *, ..., and the substring positional specifiers %1 through %9.

Usage Notes

Views are set up through the p4 client, p4 branch, or p4 label commands as part of the process of creating a client workspace, label view, or branch view respectively.

The order of mappings in a client or branch view is important. For instance, in the view defined by the following two mappings:

//depot/... //cws/...
//depot/dir1/... //cws/dir2/...

the depot will be mapped to the client workspace, and the file //depot/dir1/file.c will then be mapped to //cws/dir2/file.c. If the order of the lines in the view is reversed, however:

//depot/dir1/... //cws/dir2/...
//depot/... //cws/...

then the file //depot/dir1/file.c will be mapped to //cws/dir1/file.c, as the first mapping (mapping the file into //cws/dir2) will be overridden by the second mapping (which maps the entire depot onto the client workspace). A later mapping in a view will always override an earlier mapping.

If a path listed in a client view contains spaces, make sure to quote the path:

//depot/dir1/... "//cws/dir one/..."

Client Views

Client views are used to map files in the depot to files in client workspaces, and vice versa. A client workspace is an area in which users perform their work; files are checked out to a client workspace, opened for editing, edited, and checked back into the depot.

When files are checked out, they are copied from the depot to the locations in the client workspace to which they were mapped. Likewise, when files are submitted back into the depot, the mapping is reversed and the files are copied from the client workspace back to their proper locations in the depot.

The following table lists some examples of client views:

Client View Sample mapping
Full client workspace mapped to entire depot //depot/... //cws/...
Full client workspace mapped to part of depot //depot/dir1/... //cws/...
Some files in the depot are mapped to a different part of the client workspace //depot/... //cws/...
//depot/dir1/dir2/files.* //cws/newdir/files.*
Some files in the depot are excluded from the client workspace //depot/dir1/... //cws/...
-//depot/dir1/excludedfiles/... //cws/dir1/...
Files in the client workspace will have different names as compared to their depot names. //depot/dir1/oldname.* //cws/renamed/newname.*
Portions of filenames in the depot will be rearranged in the client workspace //depot/dir1/%1.%2 //cws/dir1/%2.%1
The files do not map the same way in each direction. Both lines will be ignored. //depot/dir1/... //cws/dir1/...
//depot/nowhere/... //cws/dir1/dir2/*

To create a client view, use p4 client. This will bring up a screen which allows you to specify which files in the depot will map to the files in your client workspace.

Branch Views

Branching of the source tree allows multiple sets of files to evolve along different paths. The creation of a branch view allows Perforce to automatically manage the file copying and edit propagation tasks associated with branching.

Branch views map existing areas of the depot (the source files) onto new areas of the depot (the target files). They are defined in a manner similar to that used for defining client views, but rather than mapping files directly into a client workspace, they merely set up mappings within the depot.

Branch View Sample mapping
New code branching off from the main codeline //depot/main/... //depot/1.1dev/...
Rearranging directories in the new release //depot/main/... //depot/1.1dev/...
//depot/main/*.c //depot/1.1dev/src/...
//depot/main/*.txt //depot/1.1dev/docs/...

To create a branch view, use p4 branch newbranch. This will bring up a screen (similar to the one associated with p4 client) and allow you to map the donor files from the main source tree onto the target files of the new branch.

No files are copied when the branch is first created. To copy the files, you must ensure that the newly-created files are included in any client workspace view intending to use those files. This may be done by adding the newly-mapped branch of the depot to your current client workspace view and performing a p4 sync command.

Label Views

Label views assign a label to a set of files in the depot. Unlike client views and branch views, a label view doesn't copy any files; it is merely a convenient way to refer to a group of files at a given revision level in order to reproduce the state of those files within a client workspace at some point in the future.

Label View Sample mapping
A new release //depot/1.1final/
The source code for the new release //depot/1.1final/src/...
A distribution suitable for clients //depot/1.1final/bin/...
//depot/1.1final/docs/...
//depot/1.1final/readme.txt

To create a label, use p4 label labelname, and enter the depot side of the view. As a label is merely a list of files and revision levels, only the depot side (i.e. the left side) of the view needs to be specified.



Perforce Command Reference:   [Index] [Prev] [Next]


Copyright 1999 Perforce Software.
Contact us at [email protected]
Last updated: 09/15/99 (Manual version 99.1.cr.6)