Perforce Public Knowledge Base - Determining the Synced Changelist of a Workspace
Downloads Blog Company Integrations Careers Contact Try Free
Menu Search
Reset Search



Determining the Synced Changelist of a Workspace

« Go Back



Finding the changelist to which a workspace is synced.


To find the sync status of a given path for your workspace, use 'p4 cstat'. 

p4 cstat //depot/path/...

... change 144089
... status have

... change 184131
... status have

... change 194325
... status have

Changes that are not fully sync'd to the workspace will have a status of 'need' or 'partial'.

The p4 cstat command was introduced in the 2010.1 version of the Perforce Server.   The reasons for this can be seen by considering the following command:

p4 changes -m1 <path>/...#have

The output of this can be imprecise when the desired result is the highest changelist to which the path is synced and some subset of files in the path are synced to an earlier changelist. The 'p4 cstat <path>/...' on the other hand command will correctly report earlier changelists that need to be synced or are only partially synced in the path.

If the imprecise semantics of the 'p4 changes -m1 <path>/...#have' command are acceptable, the following use of the 'p4 cstat <path>/...' command can be substituted:

p4 cstat <path>/... | awk 'BEGIN { change = 0 } /\.\.\. change / { candidate = $3 } /\.\.\. status / { if( $3 != "need" && candidate > change ) { change = candidate } } END { print change }'

To ignore files deleted at the head revision, use the following command:
p4 changes -m1 @clientname

replacing clientname above with the name of your client workspace.

The p4 changes command, when involked with @clientname as a revision specifier, shows the highest changelist associated with file revisions in your workspace. Typically this is the same as the last changelist that was submitted before you did a p4 sync.


  • The p4 changes command also reports changelists submitted from the workspace in question, even if they were not explicitly synced.
  • To look for deleted or added files not found by "p4 changes -m1 @clientname" run:
p4 sync -n @changelist_number

The result indicates that any files would be synced or removed
  • It is possible that a client workspace is not synced to any specific changelist.  For example, different branches under the same workspace could be synced to different changes. When checking the entire workspace the most current change is displayed.
  • Readonly clients require having P4CLIENT set, or the '-c' global equivalent, in order to access its have-list. For example, the following command can show the highest changelist number sync'ed to a read-only client:
p4 -c clientname changes -m1 //...#have
Related Links



Was this article helpful?



Please tell us how we can make this article more useful.

Characters Remaining: 255