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

<p>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?</p>

[{'answer_id': 57517, 'author': 'Mark', 'author_id': 4405, 'author_profile': 'https://Stackoverflow.com/users/4405', 'pm_score': 6, 'selected': False, 'text': '<p>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.</p>\n\n<p>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.  </p>\n\n<p>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...</p>\n\n<p>Edit:  I checked with support, and you can launch the timelapse view through p4v as follows:</p>\n\n<pre><code>p4v.exe -cmd "annotate //&lt;path/to/file&gt;"\n</code></pre>\n\n<p>HTH.</p>\n'}, {'answer_id': 57538, 'author': 'Alan', 'author_id': 2958, 'author_profile': 'https://Stackoverflow.com/users/2958', 'pm_score': 5, 'selected': True, 'text': '<p>Try taking a look at a couple of tools that I think could get you most of what you need:</p>\n\n<p>1) <a href="https://swarm.workshop.perforce.com/files/guest/jonathan_kamens/p4pr.perl" rel="nofollow noreferrer">p4pr</a> Perl script by Bob Sidebotham and Jonathan Kamens.</p>\n\n<p>2) <a href="http://www.dsmit.com/p4/" rel="nofollow noreferrer">Emacs Perforce</a> interface has a command \'p4-print-with-rev-history\' (bound to `C-x p V\'). </p>\n'}, {'answer_id': 57661, 'author': 'cdleary', 'author_id': 3594, 'author_profile': 'https://Stackoverflow.com/users/3594', 'pm_score': 1, 'selected': False, 'text': "<p>@alanw123: p4pr is close to what I'm looking for, but it doesn't cross branch boundaries:</p>\n\n<pre><code>last if $type eq 'branch';\n</code></pre>\n\n<p>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.</p>\n"}, {'answer_id': 12692671, 'author': 'Bhavesh', 'author_id': 250698, 'author_profile': 'https://Stackoverflow.com/users/250698', 'pm_score': 2, 'selected': False, 'text': '<p>From the p4v client, you can get "Time-lapse View" context menu on all the view displaying file like Files, Changelist etc.</p>\n\n<p>The time lapse view has quite a few options like Single Revision, Multiple Revision to analyze what was changed, when and by whom.</p>\n'}, {'answer_id': 16088968, 'author': 'Alexander Bird', 'author_id': 10608, 'author_profile': 'https://Stackoverflow.com/users/10608', 'pm_score': 1, 'selected': False, 'text': '<p>The <code>p4 annotate</code> command actually <em>can</em> follow merges/integrations and branching on the command line with the <code>-I</code> and <code>-i</code> commands (but it cannot do both at once :( ):</p>\n\n<pre><code>-I\nFollow integrations into the file. If a line was introduced into the file by a merge, the source of the merge is indicated as the changelist that introduced the line. If that source was itself the result of an integration, that source will be used instead, and so on.\nThe use of the -I option implies the -c option. The -I option cannot be combined with -i.\n-i\nFollow file history across branches. If a file was created by branching, Perforce includes revisions up to the branch point.\nThe use of the -i option implies the -c option. The -i option cannot be combined with -I.\n</code></pre>\n'}, {'answer_id': 25327392, 'author': 'Arnon Zilca', 'author_id': 3374591, 'author_profile': 'https://Stackoverflow.com/users/3374591', 'pm_score': 3, 'selected': False, 'text': '<p>I use a small script for blaming</p>\n\n<pre><code>#!/bin/bash\n\nFILE="$1"\nLINE="$2"\n\np4 annotate -cq "${FILE}" | sed "${LINE}q;d" | cut -f1 -d: | xargs p4 describe -s | sed -e \'/Affected files/,$d\'\n</code></pre>\n\n<p>you can hook it to some of the editors that will pass the file name and line.</p>\n\n<p>There\'s a little more complex version <a href="https://github.com/arnonzilca/p4u/blob/master/p4-annotate" rel="noreferrer">here</a>.</p>\n'}]
['https://Stackoverflow.com/questions/57467', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3594/']