1

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!

4

1 回答 1

2

好的,我不知道 SharpSVN,但我想我可以帮助...

Subversion 有一个特殊的命令叫做annotateor blameor praise。该命令的作用是列出文件中的所有行,并显示最后一行何时更改以及由谁更改。

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

这将生成一个看起来像这样的报告(嗯,不是这样的,因为这是经过处理的 Java 代码,但你明白了):

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;

第一列是更改行的版本,第二列是更改行的人。其余的是源代码行。

不是 C# 开发人员,除此之外我真的无能为力。但是,SharpSVN 有一个名为SvnBlameArgs的类,看起来它可能会做同样的事情。还有一个SvnBlameEventArgs类。

还有一个Blame方法是 SvnClient 类的一部分。我敢打赌,该SvnBlame方法是一种生成我在上面向您展示的相同类型的报告的方法。

对不起,我无能为力...

于 2013-10-14T00:18:04.503 回答