Jump to content


Determine which branches/changes contain an integration for a change

change integrate branch

  • Please log in to reply
4 replies to this topic

#1 PeteS

PeteS

    Advanced Member

  • Members
  • PipPipPip
  • 62 posts

Posted 02 July 2015 - 06:35 PM

In this thread: http://forums.perfor...ch-integration/ we learned the magic sauce for finding which changes were integrated by a given branch changelist.

Now I need to go the other direction: How can I easily determine all the branches for which a given change has been integrated? For example, if i have head, SP1, SP2 & SP3, how can I determine which branches (if any) has had change 12345 integrated?

The best I've been able to come up with is to use a script to iterate over all branches and use "p4 integrated" to test if the change still needs integrating (on Windows with cut from GNU):

for /f %i in ('p4 branches ^| cut -f2 -d" ") do p4 interchanges -b %i @=12345

	>>>>p4 interchanges -b SP1 @=12345
	Change 12345 on 2015/06/23 by goodDev@computer 'Fix 666 Stop forcing view'

	>>>>p4 interchanges -b SP2 @=12345
	No such file(s).

	>>>>p4 interchanges -b SP3 @=12345
	All revision(s) already integrated.

That's a start - it shows me that it was integrated into SP3, isn't in the mapping for SP2, and has not been integrated for SP1, but ( a ) it's really doing the reverse, telling me which branches need the integration, and ( b ) it doesn't show the CL for the integration. I've also tried "p4 filelog", but that doesn't seem to do the trick either.

Anyone have any better suggestions?

#2 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 03 July 2015 - 01:24 AM

Hi Pete,

For clarification, you are looking for which branches a change exists (was integrated in) - correct?  Have you tried the command 'p4 -ztag changes -i //depot/path/...@change,@change' to give the path? For example:

$ p4 -ztag changes -i //depot/www/review/...@398,@398
... change 398
... time 1134426710
... user vera
... client vera-reviewall-apricot
... status submitted
... changeType public
... path //depot/www/review/images/*
... desc			   Copy jamgraph ima

... change 397
... time 1134339748
... user quinn
... client quinn-dev-azalea
... status submitted
... changeType public
... path //depot/www/dev/images/*
... desc Copy jamgraph example to web de

... change 396
... time 1133734788
... user quinn
... client quinn-dev-azalea
... status submitted
... changeType public
... path //depot/Jamgraph/MAIN/images/*
... desc Add jamgraph image of jam files

$ p4 -ztag changes -i //depot/www/live/...@398,@398

If you pass the '-Ztag' to the 'p4 integrated' command it will also give you change number details. For example, instead of :

$ p4 integrated //depot/www/live/... //depot/www/review/...
//depot/www/live/Jam.html#1 - branch from //depot/www/dev/Jam.html#1
//depot/www/live/Jam.html#2 - copy from //depot/www/review/Jam.html#1
//depot/www/live/Jambase.html#1 - branch from //depot/www/dev/Jambase.html#1
//depot/www/live/Jambase.html#2 - copy from //depot/www/review/Jambase.html#1
//depot/www/live/Jamfile.html#1 - branch from //depot/www/dev/Jamfile.html#1
//depot/www/live/Jamfile.html#2 - copy from //depot/www/dev/Jamfile.html#2
//depot/www/live/Jamfile.html#3 - copy into //depot/www/dev/Jamfile.html#3
//depot/www/live/Jamlang.html#1 - branch from //depot/www/dev/Jamlang.html#1
//depot/www/live/Jamlang.html#2 - copy from //depot/www/review/Jamlang.html#1
//depot/www/live/index.html#1 - branch from //depot/www/review/index.html#1
//depot/www/live/index.html#2 - copy from //depot/www/review/index.html#2
//depot/www/live/index.html#3 - copy from //depot/www/review/index.html#3
//depot/www/review/Jam.html#1 - branch from //depot/www/dev/Jam.html#1,#2
//depot/www/review/Jam.html#1 - copy into //depot/www/live/Jam.html#2
//depot/www/review/Jambase.html#1 - branch from //depot/www/dev/Jambase.html#1,#2
//depot/www/review/Jambase.html#1 - copy into //depot/www/live/Jambase.html#2
//depot/www/review/Jamfile.html#1 - branch from //depot/www/dev/Jamfile.html#1,#3
//depot/www/review/Jamlang.html#1 - branch from //depot/www/dev/Jamlang.html#1,#2
//depot/www/review/Jamlang.html#1 - copy into //depot/www/live/Jamlang.html#2
//depot/www/review/images/jamgraph-jam.gif#1 - branch from //depot/www/dev/images/jamgraph-jam.gif#1
//depot/www/review/index.html#1 - branch from //depot/www/dev/index.html#1
//depot/www/review/index.html#2 - copy from //depot/www/dev/index.html#2
//depot/www/review/index.html#3 - copy from //depot/www/dev/index.html#3
//depot/www/review/index.html#1 - branch into //depot/www/live/index.html#1
//depot/www/review/index.html#2 - copy into //depot/www/live/index.html#2
//depot/www/review/index.html#3 - copy into //depot/www/live/index.html#3

The other way to run the command displays like this:


$ p4 -Ztag integrated //depot/www/live/... //depot/www/review/...
... toFile //depot/www/live/Jam.html
... fromFile //depot/www/dev/Jam.html
... startToRev #none
... endToRev #1
... startFromRev #none
... endFromRev #1
... how branch from
... change 365

... toFile //depot/www/live/Jam.html
... fromFile //depot/www/review/Jam.html
... startToRev #1
... endToRev #2
... startFromRev #none
... endFromRev #1
... how copy from
... change 372
.
.
.



#3 PeteS

PeteS

    Advanced Member

  • Members
  • PipPipPip
  • 62 posts

Posted 03 July 2015 - 06:08 AM

Thanks Shimada, but that doesn't quite do the trick. Let me give a more concrete example:
  • Change 86986 is submitted to //depot/head
  • That change is then integrated (via p4 integrate) to //depot/branch1 as change 87142
  • That same change is later integrated (via p4 integrate) to //depot/branch2 as change 87364
I get this when I do "p4 changes -i @=87142":

Change 87142 on 2015/06/24 by mgr@xxx '- Integration: Change 86986 fix'
Change 86986 on 2015/06/23 by dev@yyy 'Fix some bug'


And I get this when I do "p4 changes -i @=87364":

Change 87364 on 2015/06/29 by mgr@xxx '* weekly Monday merge from head'
Change 87050 on 2015/06/23 by other@zzz 'some other fix'
Change 86986 on 2015/06/23 by dev@yyy 'Fix some bug'
Change 86432 on 2015/06/22 by other@zzz 'yet another fix'


When i try "p4 -ztag changes -i //...@86986,86986", it only gives me:

... change 86986
... time 1435056535
... user dev
... client yyy
... status submitted
... changeType public
... path //depot/head/*
... oldChange 86984
... desc Fix some bug


What I'm looking for is one command that hen I query on change 86986 it will show me change 87142 on branch //depot/branch1 and change 87364 on //depot/branch2, so I can see where that change has been integrated to (i.e. which releases/products/service packs), and I'll know what other branches may still need the change integrated.

Thanks

#4 P4Sam

P4Sam

    Advanced Member

  • Members
  • PipPipPip
  • 484 posts
  • LocationSan Francisco, CA

Posted 03 July 2015 - 05:21 PM

There isn't a one-shot command to do it; "changes -i" goes back but there's no analogous command that goes forward and also lists output in the form of changelists.  I scripted something similar to this for the MediaWiki plugin way back when to take a source branch and find child branches made from it (my goal was to find changes made on child branches that hadn't been integrated back, though) -- you might take a look at that PHP code for some ideas.  My approach was to start with "p4 integrated" to find child branches.

#5 PeteS

PeteS

    Advanced Member

  • Members
  • PipPipPip
  • 62 posts

Posted 03 July 2015 - 05:57 PM

Interesting. It would be good to add a "-r" option, e.g. p4 changes -i -r to go the reverse direction.

Another approach would be a relatively simple Perl script to look for branches with $change:
  • Get a list of branches using p4 branches
  • For each branch, do p4 interchanges -b $branch @=$change; 'next' if the command does not return "already integrated"
  • Get a list of changes on that branch SINCE the $change using p4 changes "//depot/$branch/...@>$change"
  • For each change returned ($iChange), do p4 changes -i @=$iChange; 'next' if $change is not in the returned output
  • If we get here, we know $change was integrated onto $branch in CL $iChange; print the $branch and output of p4 changes -l @=$iChange
Thanks for the feedback





Also tagged with one or more of these keywords: change, integrate, branch

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users