0

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 ?

4

1 回答 1

5

正如 itowlson 在他的评论中已经回答的那样,SharpSvn 将差异写入流。因此,当函数返回时,您就在书面差异的后面。

.ReadToEnd()读取从当前位置到结尾的所有内容,这很可能是什么都没有。

用一个

stream.Position = 0;

在创建 StreamReaders 之前(或 Seek)应该会有所帮助。

这将为您提供统一的差异。如果您确实需要文件的两个版本(自己执行差异),则可以使用SvnClient.Write()单独的目标。

于 2009-12-18T10:36:10.007 回答