2016-10-14 5 views
0

SharpSVN을 사용하면 C#에서 프로그래밍 방식으로 SVN 체크 아웃을 쉽게 되돌릴 수 있지만 되돌리기를 수행하기 직전에 patch/diff 파일을 만들어야합니다.프로그래밍 방식으로 C#에서 SVN 패치/diff 파일 만들기

SharpSVN에는 SvnClient.Patch API가 있지만 docs/intellisense는 처음에는 패치 파일을 만드는 데 필요한 기능과 달리 repo에 패치를 적용하는 것으로 나타냅니다.

프로그래밍 방식으로 C#으로 SVN 패치 파일을 만들 수 있습니까?

답변

0

SVN에서 패치 파일을 만들려면 버전간에 "통합 된 Diff"파일을 만들 수도 있습니다. 다음 코드는 동일한 코드를 기반으로합니다. 지정된 개정판에서 수행 된 변경 사항에 대한 통합 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(); 

       } 
관련 문제