I want to get the latest changelist in the depot for my current client spec. This would effectively be the change that would by synced to if I did a p4 sync
in my workspace.
I tried doing p4 changes -s submitted -m1 -c [client-name]
, but that returns the most recent change that was submitted via my client.
Doing p4 changes -s submitted -m1 //depot/path/...
will work, but I don't want to have to query the client spec to figure out what the depot path is. Plus if there were more than one mapping I wouldn't know how to make sense of that.
It seems there must be a simple way to do this which I am missing.
EDIT
I did have to query the client spec, but as pointed out in the accepted answer, I could use the client spec root as the file path and didn't need to look at the view mappings.
Final solution using P4Python:
# Get client
clientspec = p4.fetch_client()
root = clientspec["Root"]
# Get latest changenum in client mapping
changes = p4.run("changes", "-s", "submitted", "-m1", root + "/...")
changenum = changes[0]['change']
I think you're going to have to query your client spec to find its local root. If you don't need to worry about AltRoots
, then this could be:
p4 changes -s submitted -m 1 "$(p4 client -o | grep "^Root:" | cut -f 2)/..."
in bash. Using your local client root instead of the depot path avoids the problem with multiple mappings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With