Perforce blame

cdleary picture cdleary · Sep 11, 2008 · Viewed 18k times · Source

Is there an equivalent of svn's blame for Perforce on the command line? p4 annotate doesn't display usernames -- only changeset numbers (without ancestor history!).

I currently have to track code back through ancestors and compare against the filelog, and there just has to be an easier way -- maybe a F/OSS utility?

Answer

Mark picture Mark · Sep 11, 2008

I'm not overly familiar with the blame command, but I assume that you are looking for who changes a particular line of code. The easiest way is to use Perforce's 'time lapse view' available from both p4win and p4v.

This tool uses annotate and some other commands to give you a view of the code line over time. You can see who modified what code, when it was inserted or removed from the codeline, etc.

It's not command line though. I checked briefly in the help and there doesnt' seem to be a way to launch the time lapse view directly from a p4win or p4v invocation. There might be though...I'll be checking further...

Edit: I checked with support, and you can launch the timelapse view through p4v as follows:

p4v.exe -cmd "annotate //<path/to/file>"

HTH.