【问题标题】:Programatically creating an SVN patch / diff file in C#以编程方式在 C# 中创建 SVN 补丁/差异文件
【发布时间】:2016-10-14 19:40:37
【问题描述】:

使用 SharpSVN,我可以在 C# 中以编程方式轻松恢复 SVN 签出,但现在我需要在执行恢复之前创建一个补丁/差异文件。

SharpSVN 具有 SvnClient.Patch API,但 docs / intellisense 表明这是用于将补丁应用于存储库,而我首先需要等效的来创建补丁文件。

如何在 C# 中以编程方式创建 SVN 补丁文件?

【问题讨论】:

    标签: c# svn tortoisesvn sharpsvn


    【解决方案1】:

    要从 SVN 创建补丁文件,您还可以跨修订创建“统一差异”文件。以下代码基于相同的。它将创建一个统一的 Diff 文件,其中包含跨指定修订所做的更改。

                    System.Uri uri = new System.Uri("your url path");
    
                    using (SvnClient client = new SvnClient())
                    {
                        SvnUriTarget from = new SvnUriTarget(uri);
    
                        // To Get the Latest Revision on the Required SVN Folder
                        SvnInfoEventArgs info;
                        client.GetInfo(uri, out info);
                        SvnRevisionRange range = new SvnRevisionRange(info.Revision - 10, info.Revision);   // The given input revisions should be valid revisions on the selected Repo path
    
                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
                        if (client.Diff(from, range, stream))
                        {
                            stream.Position = 0;    //reset the stream position to zero, as the stream position returned from Diff method is at the end.
                            System.IO.File.AppendAllText(@"C:\diffFile.patch", new System.IO.StreamReader(stream).ReadToEnd());
                        }
    
                        stream.Close();
    
                    }
    

    【讨论】:

      猜你喜欢
      • 2022-11-12
      • 2011-09-11
      • 2013-04-06
      • 2011-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-21
      相关资源
      最近更新 更多