4

In Perforce we do a lot of branching and merge. How can we find out the original changelist that one change is introduced?

For example, I submitted a changelist with id 53343 in my own private branch, and two days later, it is merged into corporation branch A, then a week later, it is merged into integration branch B, and in the end, it is merged to the main branch. Now the changelist id is a totally different one, let's say 55445, because it is a merge, which in fact inclucde a lot of changelists, maybe 300 except mine.

How can I get the original one "53343" now?

following is a more detailed description.

For example, I want to know the change history for one file in a depot range.

$ p4 changes //prod/main/platform/abc.txt
Change 560938 on 2017/04/13 by user1@user1:main 'bug fix2'
Change 559384 on 2017/03/24 by user1@user1:main 'bug fix1'
Change 559178 on 2017/03/22 by branchowner@branchowner:ws 'Merge Integration@558992 to main '

We can see in main branch it come from a merge. And use annotate

$ p4 annotate -I //prod/main/platform/abc.txt
.
.
.
554294: Monday morning
554294: I love foot ball
554294: XNES rocks
.
.
.

we can tell the change is first come from 554294

$ p4 describe 554294|more
Change 554294 by user2@user2:coorA on 2017/01/17 19:24:51
Integrate  all dev changes to coorA 

Affected files ...

.
.
.
... //prod/coorA/platform/abc.txt#1 add
.

554294 is a merge, and in this merge, file abc.txt is added. But in fact this abc.txt is not original created here. I created this abc.txt in my dev branch, but branch keeper copy it from me and did an "p4 add" in his branch. So, now for main branch, it can only see file abc.txt is original come from coorA branch. We lost the real first owner for this file, we can only trace to the branch keeper.

what we want now is get the original owner, but we lost the relationship when it is added in coorA branch, is there anyway to trace back deeper, for example, by file md5sum?

Evilight
  • 41
  • 3
  • If the "branch keeper" *manually* copied the files without telling Perforce that the files were copied (i.e., without using `p4 copy` or `p4 integrate`), you can't reasonably expect Perforce to figure out by magic where those files came from. – jamesdlin Apr 22 '17 at 23:31

2 Answers2

2

I assume you are looking at a change in a specific file. Locate that file in P4V, right-click, and choose Revision Graph. That will show you the graph of how the changes propagated. Each node in the graph is one version of the file. Merges are shown as arrows (edges), so going up the errors will bring you from 55445 to 53343.

Also, to quickly see changes between the various versions of the file, you can drag-and-drop one node of the graph to another and P4V will show you the diff.

sferencik
  • 3,144
  • 1
  • 24
  • 36
  • thank you, yes, this helps in most cases. my case is a little different..maybe wrong usage of Perforce. see above. – Evilight Apr 21 '17 at 02:14
2

As you say, change 55445 might include a lot of changes from a lot of different branches. You can view all of them by running:

p4 changes -i @55445,55445

But when you say you're trying to get the source of a more specific "change" I think what you're asking about is a particular diff within change 55445, i.e. there is a specific line in a specific file that you're trying to find the origin of. For that, run:

p4 annotate -I //depot/file

The p4 annotate command shows the revision/change that each line originated in within that file; the -I flag traces the merge relationships to find the true origin point of each line across different branches.

Source: the blog post I wrote about it several years ago. :) https://www.perforce.com/blog/101213/p4-annotate-i-going-deeper

Samwise
  • 68,105
  • 3
  • 30
  • 44
  • Thank you for your help. My case is a little different, maybe because of use Perforce in a wrong way. my case, my changelist is adding several files, and from my private branch -> corporation branch A, the branch owner use "p4 add" these files in corporation branch A which copied from my private branch, so even from "p4 annotate", the original submit is in corporation branch A..... – Evilight Apr 21 '17 at 02:11
  • This isn't really clear to me -- if these are brand new files that were added in branch A, what do they have to do with the change that was in your branch? – Samwise Apr 21 '17 at 03:27
  • can't put all in a comment, I'll have to edit the question to show what's my problem – Evilight Apr 21 '17 at 06:06
  • 2
    the "branch keeper" in your example should learn how to branch files instead of manually copying+adding them. :\ If there's no record in the history that the files are related there's not a way to build a query that follows the relationship. – Samwise Apr 21 '17 at 06:40