There are a few different methods; which one is easiest will depend on the exact context/requirements of what you're doing.
If you're interested in the specific lines of code rather than the metadata, p4 annotate
is the best way. Use p4 describe 123
to see the lines of code changed in 123, and then p4 annotate -c v5.0/(file)
to locate the same lines of code in v5.0 and see which changelist(s) introduced them into that branch. This method will work even if the changes were copied over manually instead of using Perforce's merge commands.
If you want to track the integration history (i.e. the metadata) rather than the exact lines of code (which may have been edited in the course of being merged between codelines, making the annotate
method not work), the easiest method is to use the Revision Graph tool in P4V, which lets you visually inspect a file's branching history; you can select the revision from change 123 and use the "highlight ancestors and descendants" tool to see which revisions/changelists it is connected to in other codelines. This makes it easy to see the context of how many integration steps were involved, who did them, when they happened, whether there were edits in between, etc.
If you want to use the metadata but you're trying for a more automated solution, changes -i
is a good tool. This will show you which changelists are included in another changelist via integration, so you can do p4 changes -i @123,123
to see the list of all the changes that contributed to change 123. On the other side (finding changelists in v5.0 that 123 contributed to), you could do this iteratively; run p4 changes -i @N,N
for each changelist N
in the v5.0
codeline, and see which of them include 123 in the output (it may be more than one).