Sharpsvn diff 方法不起作用

发布于 2024-08-14 18:08:43 字数 933 浏览 6 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彻夜缠绵 2024-08-21 18:08:43

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

并且 .ReadToEnd() 读取从当前位置到末尾的所有内容,这很可能什么也没有。

使用 a

stream.Position = 0;

在创建 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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文