tags:

views:

207

answers:

1

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 ?

+2  A: 

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

stream.Position = 0;

(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.

Bert Huijben