views:

1423

answers:

3
+5  Q: 

Perforce blame

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?

+11  A: 

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 annotate //<path/to/file>

HTH.

Mark
I would agree that the TimeLapse view does the job in showing exactly who change what line. Use it all the time.
Greg Whitfield
How do you launch time lapse view in p4win?
cdleary
Even if you use P4Win, you have to install P4V in order have access to the time lapse functionality. Once you do that, "Time-lapse View..." will appear on the file context menu.
raven
Howdy. The exact syntax is p4v -cmd "annotate <path_to_file>". The path may either be depot or local.
Laur
+3  A: 

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.

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

Alan
A: 

@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.

cdleary