Use p4 annotate -a.
p4 annotate [-aciIqtTu -d<flags>] file[revRange] ...
Prints all lines of the specified files, indicating the revision that
introduced each line into the file.
...
The -a flag includes both deleted files and lines no longer present
at the head revision. In the latter case, both the starting and ending
revision for each line is displayed.
...
Without the -a flag, p4 annotate shows you the revision in which each line in the given file revision was added:
C:\Perforce\test>p4 annotate foobar.java
//stream/main/foobar.java#3 - edit change 311 (text)
1: this is a sample file
2:
3: now there's some other stuff in here
With the -a flag, all of the deleted lines are shown as well, and each line is displayed with a range that shows what revisions it was present in:
C:\Perforce\test>p4 annotate -a foobar.java
//stream/main/foobar.java#3 - edit change 311 (text)
1-3: this is a sample file
2-3:
2-2: int foo = 1;
2-2: String bar = "two";
3-3: now there's some other stuff in here
The 2-2 lines were added in revision #2, and then deleted in revision #3.
You can take the revision numbers and correlate them to the history in p4 filelog to see which user created each revision and in which changelist and when:
C:\Perforce\test>p4 filelog foobar.java
//stream/main/foobar.java
... #3 change 311 edit on 2022/08/25 by Samwise@Samwise-dvcs-1509687817 (text) 'another edit'
... #2 change 310 edit on 2022/08/25 by Samwise@Samwise-dvcs-1509687817 (text) 'edit foobar'
... #1 change 309 add on 2022/08/25 by Samwise@Samwise-dvcs-1509687817 (text) 'add foobar'
or you can pass additional flags to p4 annotate to put some of that information right in the annotate output:
C:\Perforce\test>p4 annotate -atu foobar.java
//stream/main/foobar.java#3 - edit change 311 (text)
1-3: Samwise 2022/08/25 this is a sample file
2-3: Samwise 2022/08/25
2-2: Samwise 2022/08/25 int foo = 1;
2-2: Samwise 2022/08/25 String bar = "two";
3-3: Samwise 2022/08/25 now there's some other stuff in here
In P4V, you can use the "Time-Lapse View" feature to see the same information.