Perforce blame

21,185

Solution 1

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').

Solution 2

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.

Solution 3

I use a small script for blaming

#!/bin/bash

FILE="$1"
LINE="$2"

p4 annotate -cq "${FILE}" | sed "${LINE}q;d" | cut -f1 -d: | xargs p4 describe -s | sed -e '/Affected files/,$d'

you can hook it to some of the editors that will pass the file name and line.

There's a little more complex version here.

Solution 4

From the p4v client, you can get "Time-lapse View" context menu on all the view displaying file like Files, Changelist etc.

The time lapse view has quite a few options like Single Revision, Multiple Revision to analyze what was changed, when and by whom.

Solution 5

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

Share:
21,185
cdleary
Author by

cdleary

Updated on July 09, 2022

Comments

  • cdleary
    cdleary almost 2 years

    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?