Svn annotate all?

Friday 1 December 2006

Here's a thing I miss about Perforce from Subversion, and I hope there's a way I can still do it. Both systems have an annotate command, that shows for each line in the file what revision last touched it. It's a great way to figure out how your code got to be the way it is.

But the Perforce annotate command offers the -a switch. This means show all revisions of all lines. So for example, if a certain line changed three times over the lifetime of the file, all three lines would appear in the annotated output, with the range of revisions that each was current. It's a great tool for figuring out when some baffling change was introduced, so you can go back, read the checkin comment, get your head into the mindset of the time, and forensically understand the history of the code.

Is there a Subversion tool that can do this?

Comments

[gravatar]
Pete 10:40 AM on 1 Dec 2006

`svn blame` come close... it shows you who/revision is responsible for each line. Not exactly what you're looking for, but a start.

[gravatar]
Michael Chermside 11:08 AM on 1 Dec 2006

Pete: 'svn blame' is just another name for 'svn annotate'. Both show only the latest revision of each line.

Ned: I don't know of any way to do it. Clearly, one could be written using the subversion API. It would, however, be horribly slow. That may be acceptable: after all, ANALYZING such a file would be horribly slow also! Frankly, I'm surprised you find it so useful, but perhaps that's just because I haven't ever tried it.

[gravatar]
Bill Mill 12:05 PM on 1 Dec 2006

Subversion has a well-maintained python API, so I imagine it wouldn't be too hard to write.

I don't quite understand what the output of the -a command looks like - could you show some sample output?

[gravatar]
susan senator 12:27 PM on 1 Dec 2006

I think Shakespeare said, "To annotate, Perforce to change --
Ay, there's the revision."

[gravatar]
Damien Katz 5:08 PM on 1 Dec 2006

LOL Susan!

[gravatar]
Ned Batchelder 11:37 PM on 1 Dec 2006

Bill: an example of output (though not a very good one) is at http://www.perforce.com/perforce/doc.052/manuals/p4guide/08_scripting.html#1064234

[gravatar]
raj 4:37 AM on 3 Jul 2012

this link might help and give you much closer to perforce -a switch with subversion :
http://stackoverflow.com/questions/282802/how-can-i-view-all-historical-changes-to-a-file-in-svn

Add a comment:

name
email
Ignore this:
not displayed and no spam.
Leave this empty:
www
not searched.
 
Name and either email or www are required.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.