How can I track a CL's branches across multiple streams with a script

263 Views Asked by At

I'm attempting to create a script (If possible) which can fetch a specific CL from perforce and lists the streams or branch that it has been integrated into along with the CL of that integrate and maybe some other details (Like user of check in or file history)

I've been looking over some of the P4 Docs and haven't found anything yet... So wondered if anyone has experience in this area.

My end goal is to create a website (Which I had a previous company) which can display this nicely but I'd like to get the scripts up and running first.

Example: I enter CL 12345 in the script and I get a list back with each stream that change is in and the CL that change was integrated into that branch.

I know revision graph does this but I want something that can be used by non tech savy people.

Thanks!

1

There are 1 best solutions below

4
Samwise On

The command you want to base your script around is p4 filelog. Running filelog on a particular revision tells you what revisions it was integrated from and into:

C:\Perforce\test>p4 filelog @=117
//stream/main/mob/nextproject/custom/configuration
... #2 change 117 integrate on 2019/02/22 by Samwise@Samwise-dvcs-1509687817 (text) 'tada'
... ... merge from //stream/main/mob/project/configuration#2

You can do this recursively:

C:\Perforce\test>p4 filelog //stream/main/mob/project/configuration#=2
//stream/main/mob/project/configuration
... #2 change 116 edit on 2019/02/22 by Samwise@Samwise-dvcs-1509687817 (text) 'foo'
... ... merge into //stream/main/mob/nextproject/custom/configuration#2

Revision Graph does this on a single file, which is very straightforward. Doing it on a changelist basis is a little tricky unless you make some simplifying assumptions -- it is possible for a changelist to be partially integrated (i.e. not have all of its revisions get integrated), but if you simply assume that this never happens, then you can just build a bunch of revision graphs and merge them together by common changelist.