2

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 Answers1

1

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.

Samwise
  • 68,105
  • 3
  • 30
  • 44
  • Thanks for the reply. How would you suggest doing this with the chance of partial integrations? – Eddie Stubbington Jul 24 '19 at 16:31
  • 1
    That's so much more complicated I'd honestly recommend not trying it. (For context, I wrote both Revision Graph and the server-side integration logic when I worked at Perforce.) If you want to take a crack at it, though, start with the undoc `integ -C` command as a way to determine whether a historical integration was "complete". Then be prepared to discover and handle a bunch of edge cases. :D – Samwise Jul 24 '19 at 16:52
  • Thanks for that info! How would you suggest cutting out all the unneeded data? For example I want to enter the above command but simply go "This change i present in Mainline and hasn't been integrated to X, Y and Z. It can be found on B in CL's higher than 5" – Eddie Stubbington Jul 24 '19 at 19:46
  • The short answer is "write a script". :) I don't think I can pseudocode it all out in the space of a comment, but as indicated in the answer, you want to use `p4 filelog` to build a graph of the integration relationships for the revision(s) you're interested in. From there figuring out "what's downstream of this node" is very straightforward graph traversal and producing the desired output is just a matter of collating and formatting. – Samwise Jul 24 '19 at 20:07