File Specifications
Synopsis
Any file can be specified within any Perforce command in client syntax, depot syntax, or local syntax. Workspace names and depot names share the same namespace; there is no way for the Perforce service to confuse a workspace name with a depot name.
Syntax forms
Local syntax refers to filenames as specified by the local shell or operating system. Filenames referred to in local syntax can be specified by their absolute paths or relative to the current working directory. (Relative path components can only appear at the beginning of a file specifier.)
Perforce has its own method of file specification which remains unchanged across operating systems. If a file is specified relative to a client root, it is said to be in client syntax. If it is specified relative to the top of the depot, it is said to be in depot syntax. A file specified in either manner can be said to have been specified in Perforce syntax.
Perforce file specifiers always begin with two slashes
(//
), followed by the client or depot name,
followed by the full pathname of the file relative to the client or
depot root directory.
Path components in client and depot syntax are always separated by
slashes (/
), regardless of the component separator
used by the local operating system or shell.
An example of each syntax is provided below
Syntax |
Example |
---|---|
Local syntax |
|
Depot syntax |
|
Client syntax |
|
Wildcards
The Perforce system allows the use of three wildcards:
Wildcard |
Meaning |
---|---|
|
Matches all characters except slashes within one directory. |
|
Matches all files under the current working directory and all subdirectories. (matches anything, including slashes, and does so across subdirectories) |
|
Positional specifiers for substring rearrangement in filenames, when used in views. |
For example:
Expression |
Matches |
---|---|
|
Files in the current directory starting with |
|
All files called |
|
All files under the current directory and its subdirectories |
|
All files under the current directory and its
subdirectories, that end in |
|
All files under |
|
All files in the workspace or depot that is named
|
|
All files in the depot |
|
All files in all depots |
Using revision specifiers
File specifiers can be modified by appending #
or
@
to them.
The #
and @
specifiers refer to
specific revisions of files as stored in the depot:
Modifier |
Meaning |
---|---|
|
Revision specifier: The |
|
The nonexistent revision: If a revision of
This is useful when you want to remove a file from the client
workspace while leaving it intact in the depot, as in
p4 sync
The filespec |
|
The head revision (latest version) of
|
|
The revision on the current client: the revision of file last p4 synced into the client workspace. |
|
Change number: The revision of |
|
Change number: The revision of |
|
Label name: The revision of |
|
Client name: The revision of
Note that deleted files (that is, files marked for
|
|
Date and time: The revision of If no time is specified, the head revision at 00:00:00 on the morning of the date specified is returned.
Dates are specified
The datespec |
Revision specifiers can be used to operate on many files at once: p4 sync //myclient/...#4 copies the fourth revision of all non-open files into the client workspace.
If specifying files by date and time (that is, using specifiers of the
form
),
the date specification should be parsed by your local shell as a single
token. You may need to use quotation marks around the date specification
if you use it to specify a time as well as a date.
file
@datespec
Files that have been shelved can also be accessed with the
p4 diff,
p4 diff2,
p4 files, and
p4 print
commands, using the revision specifier
@=
, where
change
change
is the pending changelist number.
Some Perforce file specification characters may be intercepted and
interpreted by the local shell, and need to be escaped before use. For
instance, #
is used as the comment character in most
UNIX shells, and /
may be interpreted by
(non-Perforce) DOS commands as an option specifier. File names with
spaces in them may have to be quoted on the command line.
For information on these and other platform-specific issues, see the release notes for your platform.
Using revision ranges
A few Perforce commands can use revision ranges to modify file
arguments. Revision ranges are two separate revision specifications,
separated by a comma. For example,
p4 changes file#3,5
lists the changelists that submitted file file
at
its third, fourth, and fifth revisions.
Revision ranges have two separate meanings, depending on which command you're using. The two meanings are:
-
Run the command on all revisions in the specified range. For example, p4 jobs //...#20,52 lists all jobs fixed by any changelist that submitted any file at its 20th through 52nd revision.
Revision ranges implicitly start at #1, for example, p4 fixes //depot/file.c#5 implies all jobs fixed by revisions 1 through 5. (To see only those jobs that were fixed by revision 5, you would have to specify p4 fixes //depot/file.c#5,5)
This interpretation of revision ranges applies to p4 changes, p4 fixes, p4 integrate, p4 jobs, and p4 verify.
-
Run the command on only the highest revision in the specified range. For example, the command p4 print file@30,50 prints the highest revision of file
file
submitted between changelists 30 and 50. This is different than p4 print file@50: if revision #1 of filefile
was submitted in changelist 20, and revision #2 of filefile
was submitted in changelist 60, then p4 print file@30,50 prints nothing, while p4 print file@50 prints revision #1 offile
.The commands p4 files, p4 print, and p4 sync all use revision ranges in this fashion.
Revision ranges can be very powerful. For example, the command
p4 changes
file#3,@labelname
lists all changelists that submitted file file
between its third revision and the revision stored in label
labelname
.
Limitations on characters in filenames and entities
To support internationalization, Perforce permits the use of printable non-ASCII characters in filenames, label names, client workspace names, and other identifiers.
The pathname component separator (/
) is not
permitted in filenames, depot names, or client workspace names, but can
appear in label names, job names, or user names. The recursive
subdirectory wildcard (...
) is not permitted in file
names, label names, or other identifiers.
Character |
Reason |
---|---|
|
Perforce wildcard: matches anything, works at the current directory level and includes files in all directory levels below the current level. |
|
Perforce separator for pathname components. |
To refer to files containing the Perforce revision specifier wildcards
(@
and #
), file matching wildcard
(*
), or positional substitution wildcard
(%%
) in either the file name or any directory
component, use the ASCII expression of the character's hexadecimal
value. ASCII expansion applies only to the following four characters:
Character |
ASCII expansion |
---|---|
|
|
|
|
|
|
|
|
To add a file such as [email protected]
, force a
literal interpretation of special characters by using:
p4 add -f //depot/path/[email protected]
When you submit the changelist, the characters are automatically expanded and appear in the change submission form as follows:
//depot/path/status%40june.txt
After submitting the changelist with the file's addition, you must use the ASCII expansion in order to sync it to your workspace or edit it within your workspace:
p4 sync //depot/path/status%40june.txtp4 edit //depot/path/status%40june.txt
Most special characters tend to be difficult to use in filenames in
cross-platform environments: UNIX separates path components with
/
, while many DOS commands interpret
/
as a command line switch. Most UNIX shells
interpret #
as the beginning of a comment. Both
DOS and UNIX shells automatically expand *
to match
multiple files, and the DOS command line uses %
to
refer to variables.
Similarly, although non-ASCII characters are allowed in filenames and Perforce identifiers, entering these characters from the command line may require platform-specific solutions. Users of GUI-based file managers can manipulate such files with drag-and-drop operations.