1

I have a big project and I want to find all the users who have used specific keywords in the code (eg. "goto"). Doing p4 annotate on all the files will take a lot of time.

Is there a way to quickly do p4 annotate on a single line of a given file?

nav_jan
  • 2,473
  • 4
  • 24
  • 42

2 Answers2

2

Do you really care about uses of 'goto' that are no longer present in the code (i.e., uses that were added and then later removed?

I suggest not; that simplifies the search.

If you start with p4 grep -e goto //project/file/path/..., you will find out which files currently contain that word. Then you only have to examine those files.

Then, for each file, you can run `p4 annotate -u //project/file/name | grep goto' and see which change(s) added the word 'goto' to that file.

Then you can examine the results.

By the way, if your server is at version 2015.2 or higher, you can use the new '-u' flag added by

    #1233417 (Bug #12755) **
    'p4 annotate' now supports a new flag '-u'. This flag instructs
    annotate to display the user who modified the change and the date
    when the modification occurred.

this will help you with your final report because you won't have to do the extra step of looking up each changelist to see who submitted it.

Bryan Pendleton
  • 16,128
  • 3
  • 32
  • 56
  • But still I have to do p4 annotate on full file (multiple files in my case) instead of unique lines of the code from multiple files. – nav_jan Sep 02 '16 at 15:08
0

I think users expect behavior like git blame from p4 annotate, but we shouldn't.

This would be a very useful feature if it existed, however according to the official p4 documentation it does not, maybe for the same reason why you can't "chain" p4 changes, or maybe because p4 is not aware of the lines each change is on your local copy.

Either way, if it would only show line numbers we would be able to combine with a simple grep command and jump to the line easily, however that also doesn't exist.

As a workaround you I use this: p4 annotate -u -c [file] | grep [line content]