Views

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
  • Label views associate groups of files in the depot with a single label.

Each type of view consists of lines that 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 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 is necessary because the files are automatically 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 mappings are overridden.
  • Mappings beginning with a hyphen (-) specifically exclude any files that match that mapping.
  • In client views, mappings beginning with a plus sign (+) overlay previous mappings. (Overlay mappings do not apply to branch or label views.)

File specifications within mappings are provided in the usual Helix Core Server syntax, beginning with //, followed by the depot name or workspace name, and followed by the actual file name(s) within the depot or workspace. (You cannot use revision specifiers in views.)

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 because a later mapping in a view always overrides an earlier mapping.

For example, in the view defined by the following two mappings:

//depot/...     //ws/...
//depot/dir/... //ws/dir2/...

the entire depot is mapped to the client workspace, but the file //depot/dir/file.c is mapped to //ws/dir2/file.c and overrides the previous mapping.

If the order of the lines in the view is reversed,

//depot/dir/... //ws/dir2/...
//depot/...     //ws/...

the file //depot/dir/file.c is mapped to //ws/dir/file.c because the second mapping overrides by the first mapping.

Spaces in path and file names

If a path or file name in a workspace view, branch view, or label view contains spaces, use quotes (") to enclose the path:

//depot/v1/... "//ws/version one/..."

Special characters in path and file names

To map file and directory names that contain the characters @, #, *, or %, (that is, to interpret such characters as components of path and filenames, and not as Helix Core Server wildcards), expand the characters to their ASCII equivalents :

Character ASCII expansion

@

%40

#

%23

*

%2A

%

%25

Client Views

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

When files are synced, 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 files are copied from the client workspace 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/... //ws/...

Full client workspace mapped to part of depot

//depot/dir/... //ws/...

Some files in the depot are excluded from the client workspace with the hyphen (-)

//depot/dir/...           //ws/...
-//depot/dir/exclude/...  //ws/dir/exclude/...

Some files in the depot are mapped to a different part of the client workspace

//depot/...       //ws/...
//depot/rel1/...  //ws/release1/...

Files in the client workspace are mapped to different names than their depot names.

//depot/dir/old.* //ws/renamed/new.*

Portions of filenames in the depot are rearranged in the client workspace

//depot/dir/%%1.%%2 //ws/dir/%%2.%%1

By default, if two lines map to the same place in the workspace, the first line is ignored.

//depot/dir1/... //ws/build/...
//depot/dir2/... //ws/build/...

An overlay mapping with the plus (+) sign allows "many-to-one" mapping. Files from more than one depot directory map to the same place in the workspace.

//depot/dir1/...  //ws/build/...
+//depot/dir2/... //ws/build/...
A ditto mapping with the ampersand (&) sign allows "one-to-many" mapping. Files from the depot map to more than one location in the workspace. Note that workspace files on a line that begins with & are read-only.
//depot/shared/include/...  //ws/dir1/include/...
&//depot/shared/include/...  //ws/dir2/include/...

To create a client view, use p4 client to bring up a screen where you can specify how files in the depot are mapped to the files in your client workspace.

Note

A view spec can map files in a depot of type graph. For details, see the section Including Graph Depot repos in your client in the topic p4 client.

Branch Views

Branching of the source tree allows multiple sets of files to evolve along different paths. The creation of a branch view allows Helix Core Server 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. Because integration can take place in either direction, every line in a branch view must be unambiguous in both directions; overlay mappings are therefore not permitted in branch views.

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/*.c
//depot/main/*.txt //depot/1.1dev/doc/*.txt

To create a branch view, use this syntax:

p4 branch newbranch

This command brings up a screen (similar to the one associated with p4 client) and allows you to map the donor files from the main source tree onto the target files of the new branch.

No files are copied when a branch view is first created. To copy the files, you must ensure that the newly-created files are included in any client view intending to use those files. You can do this by adding the newly-mapped branch of the depot to your current client 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 does not copy any files; label views are used to limit the set of files that are taggable by a label.

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/doc/...
//depot/1.1final/readme.txt

To create a label, use p4 labellabelname, and enter the depot side of the view. Because a label is merely a list of files and revision levels, only the depot side (the left side) of the view needs to be specified, and overlay mappings are not permitted.