Perforce blame

Viewed 22889

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?

6 Answers

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.

Try taking a look at a couple of tools that I think could get you most of what you need:

1) p4pr Perl script by Bob Sidebotham and Jonathan Kamens.

2) Emacs Perforce interface has a command 'p4-print-with-rev-history' (bound to `C-x p V').

@alanw123: p4pr is close to what I'm looking for, but it doesn't cross branch boundaries:

last if $type eq 'branch';

That was the main problem I had when I tried writing my own utility -- you can't (easily) tell how the lines map back to the file that was branched from.

Related