How to export changed files between two SVN revisions

前端 未结 6 1119
旧时难觅i
旧时难觅i 2021-02-09 00:57

How can I export changed files in SVN that have changed between two revisions. I need a solution either via command line or by using any scripts (with proper folder structure).

6条回答
  •  旧时难觅i
    2021-02-09 01:18

    As far as I know, svn does not provide such a feature. But you may write a simple c# program using SharpSVN to do it. Here is a sample that you can use. In this sample, I am getting the whole changed file from revision 100 to 200.

    using SharpSvn;
    using System.IO;
    using System.Collections.ObjectModel;
    using Microsoft.VisualBasic;
    
    namespace SvnDiffExporter
    {
        class Program
        {
            static void Main(string[] args)
            {
                SvnClient client = new SvnClient();
                SvnRevisionRange range = new SvnRevisionRange(100, 200);
                MemoryStream result = new MemoryStream();
    
                Collection items;
                SvnLogArgs logargs = new SvnLogArgs(range);
                client.GetLog(@"e:\Artifacts", logargs, out items);
    
                int i = 0;
                string [] path = new string[255];
                foreach (SvnLogEventArgs ar in items)
                {
                    foreach (SvnChangeItem changeitem in ar.ChangedPaths)
                    {
                        if (changeitem.Action != SvnChangeAction.Delete)
                        {
                            path[i] = changeitem.Path;
                            i++;
                        }
                    }
                }
    
                string localpath = @"c:\data";
                foreach (string str in path)
                    client.Export(str, localpath);
            }
        }
    }
    

提交回复
热议问题