2011-07-01 10 views
0

SharpSVN을 사용하여 텍스트 비교를 수행하는 파일의 이전 버전을 얻는 효율적인 방법을 찾으려고합니다.SharpSVN - 이전 버전을 얻는 방법?

using (SvnClient c = new SvnClient()) 
{ 
    c.Authentication.DefaultCredentials = new NetworkCredential(
      ConfigurationManager.AppSettings.Get("SvnServiceUserName") 
     , ConfigurationManager.AppSettings.Get("SvnServicePassword") 
     , ConfigurationManager.AppSettings.Get("SvnServiceDomain") 
     ); 
    c.Authentication.SslServerTrustHandlers += new EventHandler<SvnSslServerTrustEventArgs>(Authentication_SslServerTrustHandlers); 

    Collection<SvnFileVersionEventArgs> fileVersionCollection = new Collection<SvnFileVersionEventArgs>(); 
    SvnRevisionRange range = new SvnRevisionRange(0, this.hooks.Revision); 
    SvnFileVersionsArgs args = new SvnFileVersionsArgs(); 
    args.RetrieveProperties = true; 
    args.Range = range; 

    foreach (SvnChangeItem item in log.ChangedPaths) 
    { 
     string path = this.repositoryPath + item.Path; 

     bool gotFileVersions = false; 

     try 
     { 
      if (item.NodeKind == SvnNodeKind.File) 
       gotFileVersions = c.GetFileVersions(SvnTarget.FromString(path), args, out fileVersionCollection); 

위 코드는 내 요청을 수행하는 예제이지만 매우 비효율적입니다. 나의 목표는 리비전과 이전 리비전을 선택할 수있게하는 것입니다. 예를 들어, 내 저장소가 r185에 있지만 개정 100에서 파일을보고 싶고 동일한 파일의 이전 개정판을보고 싶다면 (이것이 무엇인지는 알 수 없습니다) 어떻게이 작업을 수행 할 수 있습니까?

나는 c.GetInfo()를 보았지만 이것은 가장 최근의 커밋으로 이전 버전을 얻는 것으로 보인다.

감사합니다.

답변

1

찾고있는 버전 만 사용해보세요. logSvnLoggingEventArgs의 인스턴스라고 가정합니다. 당신이 해당 버전에서 변경 사항을 검색 할 수 있습니다

args.Range = new SvnRevisionRange(log.Revision, log.Revision - 1); 

그 방법, 그리고 log.Revision는 변화의 개정 번호로 보장되어 있기 때문에, 당신은 하나를 뺄 경우 :

는이 경우 사용 당신은 이전 버전을 가지고 있습니다.

0

이전 버전 (마지막 커밋 이전 버전) 또는 로컬의 수정되지 않은 버전이 필요합니까?

Subversion의 작업 카피 라이브러리는 작업 및 자료에 대한 이러한 버전은 SvnClient.Write()를 사용할 수

using (SvnClient c = new SvnClient()) 
using (Stream to = File.Create(@"C:\temp\my.tmp")) 
{ 
    c.Write(new SvnPathTarget(@"F:\projects\file.cs", SvnRevision.Base), to); 
} 

파일 중 하나를 얻으려면 다음의 '마법'버전

Working (SvnRevision.None)  - What you have in your working copy 
            (includes local modifications) 

Head  (SvnRevision.Head)  - The last committed version of a url in the 
            repository 

Base  (SvnRevision.Base)  - The version you last committed or updated to. 

Committed (SvnRevision.Comitted) - The last revision <= BASE in which the path was 
            modified 

Previous (SvnRevision.Previous) - The last revision before Committed. 
            (Literally Committed-1) 

있다 로컬로 사용할 수 있습니다. 다른 버전의 Subversion은 저장소에 접속해야합니다.

관련 문제