So What Perforce Changelist Have I Got?

I’ve just used Perforce for the first time on a big project, and it was … ok. Feature-wise I’d use Git, Mercurial or Accurev in an instant instead, but I suspect that both the project’s history and scale were the reason behind using Perforce. Unlike all of the above Perforce has per-file versioning, rather than per-repository versioning. Commits to the repository are a sequence of changelists, each of which, presumably, must internally list out the revisions of each file in the repository. It didn’t seem to be widely known how to query Perforce to ask local workspace what the current changelist you have is. A bit of digging reveals that:

p4 changes -m1 /...#have -s submitted

Does the trick.

In Perforce you can update any file to any revision of that file, separate from updating to a changelist. In that case I’m not sure what the command will give back, but clearly a single changelist number can’t fully describe a local workspace where even a single file has been updated separate from a changelist.

Advertisement