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

file#n

Revision specifier: The nth revision of file.

file#none

file#0

The nonexistent revision: If a revision of file exists in the depot, it is ignored.

This is useful when you want to remove a file from the client workspace while leaving it intact in the depot, as in p4 syncfile#none.

The filespec #0 can be used as a synonym for #none - the nonexistent revision can be thought of as the one that "existed" before the first revision was submitted to the depot.

file#head

The head revision (latest version) of file. Except where explicitly noted, this is equivalent to referring to the file without a revision specifier.

file#have

The revision on the current client: the revision of file last p4 synced into the client workspace.

file@n

Change number: The revision of file immediately after changelist n was submitted.

file@=n

Change number: The revision of file at the specified changelist number n.

n can be a submitted or a shelved change number; it can’t be a pending (non-shelved) change number.

file@labelname

Label name: The revision of file in the label labelname.

file@clientname

Client name: The revision of file last taken into client workspace clientname.

Note that deleted files (that is, files marked for delete at their latest revision) are not considered to be part of a workspace.

file@datespec

Date and time: The revision of file at the date and time specified.

If no time is specified, the head revision at 00:00:00 on the morning of the date specified is returned.

Dates are specified yyyy/mm/dd:hh:mm:ss or yyyy/mm/ddhh:mm:ss (with either a space or a colon between the date and the time).

The datespec @now can be used as a synonym for the current date and time.

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 file@datespec), 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.

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 @=change, where 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.