2011-07-01 8 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は、あなたが1を引いた場合、変更のリビジョン番号であることが保証されているので、あなたは以前のバージョンを持っています。

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では、リポジトリに接続する必要があります。

関連する問題