Question

Is there any easy way to determine which commit a specified line of a file was last modified, with SharpSVN?

Let's say I have the following three commits:

Commit 1:

Hello

Commit 2:

Hello, World!

Commit 3:

Hello, World!
Hi There :D

I'd be looking for some kind of function that does the following:

LastMod(lineNum: 1); //returns 2, since the first line was last modified in commit 2
LastMod(lineNum: 2); //returns 3, for the same reason

I'd need to do this on a rather large scale (large SVN repositories, with hundreds/thousands of lines per file) so just 'brute force' comparing each line from each previous commit probably wouldn't work. Not sure if SVN provides an implementation for what I'm looking for, I'm new to SVN and SharpSVN.

Thanks!

Was it helpful?

Solution

Okay, I have no idea about SharpSVN, but I think I can help...

Subversion has a special command called annotate or blame or praise. What this command does is list out all the lines in a file, and show you when that last line was changed and by whom.

C> REM: produce an annotated report on foo.c#
C> svn blame foo.c# 

This will produce a report that looks something like this (Well, not anything like this because this is munged Java code, but you get the idea):

109990     jevans package com.tc.cache.frontend;
109990     jevans 
109990     jevans import com.tangosol.net.CacheFactory;
109990     jevans import com.tangosol.net.NamedCache;
140072 dweintraub import java.util.ArrayList;
136130 ihroseline import java.util.List;
136130 ihroseline import java.util.Map;
123931     bfelds import org.apache.commons.logging.Log;
109990     jevans import org.apache.commons.logging.LogFactory;

The first column is the revision where the line was changed and the second column is who changed the line. The rest is the source code line.

Not being a C# developer, I really can't help too much beyond that. However, SharpSVN has a class called SvnBlameArgs that looks like it might do the same thing. There's also a SvnBlameEventArgs class.

There's also a Blame method that's part of the SvnClient class. I am willing to bet that the SvnBlame method is a way of producing that same type of report I showed you above.

Sorry I can't help beyond this...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top