Return current changeset

Is there an api or CLI command that can be used to return the number of the current changeset for the workspace?

I’ve discovered this command: cm status --nochanges

returns the changeset as part of the output. However, is there an API command the replicates this? I’ve been searching the documentation but don’t see this in any outputs.

The magic command is:

cm find "changeset order by changesetid desc limit 1" --format={changesetid} --nototal

Note this will always be the latest changesetid, independent of the branch you are currently on, and independent of on which branch that changeset is on.

See here for reference: update to latest changeset of ANY branch using command line? - General - Plastic SCM Community

EDIT: oh sry, I just noticed you are interested in teh CURRENT changeset, not the latest one…

The best I could find for the CURRENT changeset is something like:

cm status --compact --nochanges

which outputs a syntax in the form of:

cs:XXXX@rep:REPONAME@repserver:SERVERNAME

Or:

cm status --xml --nochanges

where the multi-line output contains exactly one line with:

<Changeset>XXXX</Changeset>

So in both cases you’ll need some string processing to get JUST the number.
Unfortunately, the “status” command doesn’t seem to have a “–format” option.