Sharpsvn diff 方法不起作用
我正在尝试使用 Sharpsvn 实现 diff 方法。我的代码片段如下
private void Diff(string pSourcePath)
{
Uri UriSCPath = new Uri(pstrSourcePath);
SvnClient DPISVN_Clnt = new SvnClient();
DPISVN_Clnt.Authentication.DefaultCredentials = new NetworkCredential("Biju","Biju");
try
{
SvnRevisionRange objSvnRevisionRange=new SvnRevisionRange (17157,17161);
Stream stream=null;
MemoryStream objMemoryStream = new MemoryStream();
bool b = DPISVN_Clnt.Diff(pstrSourcePath, objSvnRevisionRange, objMemoryStream);
StreamReader strReader = new StreamReader(objMemoryStream);
string str = strReader.ReadToEnd();
}
我的第一个问题是 Diff 方法在我的程序中总是返回 true。我更改了我的修订范围,它也返回 true。
我的第二个问题是 diff 方法有一个输入参数名称 Stream result。我认为它包含结果流信息。当我尝试使用 Streamreader 读取结果流的内容时,它返回空字符串。但是我的修订范围不同,并且我的源文件中存在一些差异。
使用stream的方法是一样的吗?
I am trying to implement diff method using sharpsvn. My code snippet as follows
private void Diff(string pSourcePath)
{
Uri UriSCPath = new Uri(pstrSourcePath);
SvnClient DPISVN_Clnt = new SvnClient();
DPISVN_Clnt.Authentication.DefaultCredentials = new NetworkCredential("Biju","Biju");
try
{
SvnRevisionRange objSvnRevisionRange=new SvnRevisionRange (17157,17161);
Stream stream=null;
MemoryStream objMemoryStream = new MemoryStream();
bool b = DPISVN_Clnt.Diff(pstrSourcePath, objSvnRevisionRange, objMemoryStream);
StreamReader strReader = new StreamReader(objMemoryStream);
string str = strReader.ReadToEnd();
}
My first issue is Diff method always returns true in my program.I changed my revison range than also it returns true.
My second issue is in diff method have an input parameter names Stream result.I think it contains resulted stream info. When i try to read the contents of a result stream using streamreader it returns empty string.But my revison range is different and there is some difference is present in my source file.
Is the same way to use stream ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 itowlson 已经在评论中回答的那样,SharpSvn 将差异写入流中。因此,当函数返回时,您就位于写入的差异后面。
并且
.ReadToEnd()
读取从当前位置到末尾的所有内容,这很可能什么也没有。使用 a
在创建 StreamReaders 之前
(或 Seek)应该会有所帮助。这将为您提供统一的差异。如果您确实需要文件的两个版本(自己执行比较),则可以使用单独目标的
SvnClient.Write()
。As itowlson already answered in his comment, SharpSvn writes the diff to the stream. So when the function returns you are right behind the written diff.
And
.ReadToEnd()
reads everything from the current position to the end, which is most likely nothing.Using a
(or Seek) before creating the StreamReaders should help.
This will give you a unified diff. If you really need both versions of the file (to perform the diff yourself), you can use
SvnClient.Write()
of the separate targets.