Get the changelist number of current workspace directory
Asked Answered
J

8

35

Each time we do a build, we have to record the changelist number of source files for tracking. We have different projects (under different directories) and they are synced at different changelist number. May you please show me how can we get the changelist number of a specific directory?

Jayme answered 16/3, 2012 at 3:26 Comment(1)
Perhaps a label would be useful. The label can record the revisions of the files that you built.Jacqui
P
47

Also, there's p4 changes -m1 //path/to/your/project/...#have which, if run in the client workspace that synced the files for building, will give you the highest changelist number of the files in the workspace.

Peacock answered 16/3, 2012 at 20:27 Comment(5)
This looks great, but I get "Request too large (over 550000); see 'p4 help maxresults'." error. I just love Perforce, so full of surprises...Rheotaxis
For some reason, p4 changes -m1 ...#have in the workspace root is giving me a revision 2 days older than the day workspace was synced. Why can this be?Equivalent
this gives changelist of the submitted , how can we get the pending changelist if its present ?Ordain
To get the pending change list number p4 changes -c ${CLIENT_NAME}Cloudless
carefull here if the latest change(s) synced to your workspace only contain deletes these will not be reported. this command will return the highest change reflected by files in the workspace... deleted files are not in the workspace thus cannot be reported. as far as I know.. there is no way to know for sure what the changelist is for a workspaceHygienic
A
11

You can also use the short version p4 changes -m1 #have if you don't want to specify the directory.

If you are using a shell for which "#" is a comment character like bash, remember to escape it as follows: p4 changes -m1 \#have

Avigdor answered 8/7, 2014 at 9:23 Comment(4)
Note that this is not the same thing as user1054341's answer that includes the depot path. This version seems to include changes that have not yet been synced by the client.Intervene
Yeah, no. Like solublefish says, this gives the newest changelist on the server, which is not at all the changelist i have synced my client view to.Ruhnke
@Intervene @Ruhnke I think your shell may be silently ignoring the #have part because that command works exactly as advertised.Opus
single quotes work in bash-like shells p4 changes -m1 '#have'Iva
S
7
p4 cstat //path/to/your/project...#have |grep -B1 have|tail -n2

@thegeko, this does not require high max_scanrows perforce limits

Stylite answered 28/3, 2017 at 12:11 Comment(3)
What do you mean "high max_scanrows perforce limits"?Gabler
See accepted answer above and the comment from thegeko (not thegeco) about it failing because the request was too largeDebauchee
Looks like the secret to avoid "Request too large" error is not this specific command, but giving Perforce a depot path, not the local path. With depot path, p4 changes ... #have works too.Equivalent
A
1

If your build system always syncs to head on the directory before building, you can use p4 changes -m 1 //path/to/your/project/... to get the head changelist number for that directory.

If you go with this method, I would suggest running the changes command before syncing, and then explicitly syncing to that changelist. That should eliminate the chance of someone checking in between the changes command and the sync command.

Aggressive answered 16/3, 2012 at 17:20 Comment(0)
H
0

I use the "lazy manual way" (aka I don't know better) within the P4V client:

Use this in the "Submitted" tab filters: //yourproject/...#>have And it will show you which CLs you haven't synched, note the oldest one. Remove the #>have filter and see what's the CL that came before the one you just noted.

Hern answered 1/8, 2017 at 12:54 Comment(0)
A
0

From within the directory:

p4 changes -m1 //...#have
Aqaba answered 21/10, 2022 at 23:18 Comment(0)
B
0

Using just the workspace path, p4 changes -m1 /path/to/your/workspace/...#have (or cd /path/to/your/workspace; p4 changes -m1 $(pwd)/...#have) gives you the highest changelist number of the files in the workspace. This is similar to the accepted answer above from user1054341 p4 changes -m1 //your-client-name...#have, but you don't have to remember the client name.

A path to a subdirectory in the client gives you the latest changelist in that subdirectory and its children, e.g. p4 changes -m1 /path/to/your/workspace/src/module1/...#have. This can be run from any directory within the workspace.

Omitting #have shows the latest changelist checked in to the depot.

These commands must be run from a directory in the workspace.

Blowhole answered 1/2, 2023 at 18:46 Comment(0)
B
-1

In my case, I just want to know what changelist number is opened (not syned to) in a specific directory. For that, I do:

p4 opened -s | cut -d' ' -f5 | uniq
Bankbook answered 1/11, 2017 at 23:6 Comment(1)
sure but that`s not what the OP askedHygienic

© 2022 - 2025 — McMap. All rights reserved.