"SVN Blame" plugin for VisualStudio

The daily builds of AnkhSVN 2.0 have a completely new annotate (blame) implementation inspired by the TFS annotate feature.

AnkhSVN Annotate Preview
(source: qqn.nl)

Not really visible in these screenshots, but it uses the Visual Studio editor for syntax coloring, etc. (You can see the sizeof() in the right bottom of the next image is blue). As you can see in the second picture it also allows several commands on the revision regions in the left bar.

It currently doesn't implement the jump to active line. But you can use the Visual Studio goto line (Ctrl+G) command in it. (You might be able to script this in a macro)

The easiest way to start annotate is right click on the editor ->Subversion->Annotate.

AnkhSVN Annotate Commands
(source: qqn.nl)

[Update 2009-02-03: This feature is now commonly available in the new Stable release]


I use a set of external tools wired to TortoiseProc.exe to perform SVN operations like log, diff, blame, revert, commit, update, etc. Then I create toolbar shortcuts to these external tools so that I have all the basic SVN operations accessible within the IDE.

Here are the steps to create a button to do a blame on the current file:

  1. Go to tools -> external tools and click "Add"
  2. Enter whatever title you want (e.g. "Blame")
  3. For the command, enter the following (the path will be different if you installed TortoiseSVN to a different directory): c:\Program Files\TortoiseSVN\bin\TortoiseProc.exe
  4. For the arguments, enter the following: /command:blame /path:"$(ItemPath)" /notempfile
  5. For the initial directory, enter:$(ItemDir)

Now, whenever you have a file open, simply go to tools -> Blame and it should generate the Blame in a popup window. You can also customize the toolbar and create a shortcut for this external tool to make it even easier.


In VisualSVN supports blame to some extent - you can right-click on a file and select "Blame". However, it pops up a new window, which may not be as integrated as you want.


I wrote a Visual Studio macro to get line number info and pass it to tortoiseproc.exe (which is part of TortoiseSVN)

Take a look at the parameter info: http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-automation.html

Here is my macro:


Sub Blame()
  sCurrFileFull = DTE.ActiveDocument.FullName
  Dim activeDoc As Document
  activeDoc = DTE.ActiveDocument
  Dim nLine As Integer
  nLine = activeDoc.Selection.CurrentLine

  sShellCommand = sTorEXE & " /command:blame /startrev:1 /endrev:-1 /path:""" &
                   sCurrFileFull & """ /notempfile /line:" & nLine.ToString()
  Shell(sShellCommand, AppWinStyle.MaximizedFocus, False)
End Sub