2009-05-07 11 views
3

私はWindows 2003サーバーにVisualSVNをインストールし、匿名の読み取りアクセスを提供するように設定しました。私の理解から、VisualSVNはApacheと公式のSVNリポジトリサーバを使用しています。オンザフライでのSVNへ

ここでは、「HEAD as ZIP」機能を提供するためにSVN Webページを拡張したいと考えています。 SourceForgeCodeplexのようなWebポータルは、この機能を提供します。

このためのSVNリポジトリサーバー用のプラグインはありますか?または別のWebクライアント(できればASP.NET)ですか?

+0

serverfault.comで投稿する – stukelly

+0

@stukelly - disagree; SVNはit-proのものよりも "dev"なものです。 –

+0

@stukelly - 私はserverfault.comへのアクセス権がありません。さらに、私は開発者です。私は良いカスタムソリューションを開発する用意ができています。ですから、私は既製の製品だけではありません。 – tofi9

答えて

5

私は解決策を見つけました。他の誰かが同じ解決法を達成したいと思っている場合は、解決策を見つけました。

WebSvnを分析した結果、SVNエクスポートディレクトリ機能を使用して、ソースをローカルフォルダにダウンロードし、そのディレクトリを即座に圧縮していることがわかりました。パフォーマンスはかなり良いです。

私の解決策は、以下のC#でSharpSVNDotNetZipを使用しています。完全なソースコードはmy SVN repositoryにあります。

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using SharpSvn; 
using Ionic.Zip; 
using System.IO; 
using SharpSvn.Security; 

namespace SvnExportDirectory 
{ 
    public class SvnToZip 
    { 
     public Uri SvnUri { get; set; } 
     public string Username { get; set; } 
     public string Password { get; set; } 

     private bool passwordSupplied; 

     public SvnToZip() { } 

     public SvnToZip(Uri svnUri) 
     { 
      this.SvnUri = svnUri; 
     } 

     public SvnToZip(string svnUri) 
      : this(new Uri(svnUri)) { } 

     public void ToFile(string zipPath) 
     { 
      if (File.Exists(zipPath)) 
       File.Delete(zipPath); 

      using (FileStream stream = File.OpenWrite(zipPath)) 
      { 
       this.Run(stream); 
      } 
     } 

     public MemoryStream ToStream() 
     { 
      MemoryStream ms = new MemoryStream(); 
      this.Run(ms); 
      ms.Seek(0, SeekOrigin.Begin); 
      return ms; 
     } 

     private void Run(Stream stream) 
     { 
      string tmpFolder = 
       Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); 

      try 
      { 
       using (SvnClient client = new SvnClient()) 
       { 
        //client.Authentication.Clear(); 
        client.Authentication.UserNamePasswordHandlers += Authentication_UserNamePasswordHandlers; 

        SvnUpdateResult res; 
        bool downloaded = client.Export(SvnTarget.FromUri(SvnUri), tmpFolder, out res); 
        if (downloaded == false) 
         throw new Exception("Download Failed"); 
       } 

       using (ZipFile zipFile = new ZipFile()) 
       { 
        zipFile.AddDirectory(tmpFolder, GetFolderName()); 
        zipFile.Save(stream); 
       } 
      } 
      finally 
      { 
       if (File.Exists(tmpFolder)) 
        File.Delete(tmpFolder); 
      } 
     } 


     private string GetFolderName() 
     { 
      foreach (var potential in SvnUri.Segments.Reverse()) 
      { 
       if (string.Equals(potential, "trunk", StringComparison.InvariantCultureIgnoreCase) == false) 
        return potential; 
      } 
      return null; 
     } 

     void Authentication_UserNamePasswordHandlers(object sender, SvnUserNamePasswordEventArgs e) 
     { 
      if (passwordSupplied) 
      { 
       e.Break = true; 
      } 
      else 
      { 
       if (this.Username != null) 
        e.UserName = this.Username; 

       if (this.Password != null) 
        e.Password = this.Password; 

       passwordSupplied = true; 
      } 
     } 
    } 
} 
1

私は「内蔵の」知りませんが、あなたが仕事をするSharpSVNと#ZipLibを使用しているページを書いてみてください...それは遅すぎると

、あなたはおそらくどちらか使用することができますあらかじめ準備されたジップをあなたが戻すことができる場所に便利に保つためのコミット・フックまたはスケジュールされたジョブ(数分おきなど) - 「別の名前として作成して準備ができたら名前を変更する」トリックを使用して時間を最小限に抑えるロックされている/利用できません。または、リビジョン番号で名前を付けます。

+0

それは考えです。私はオンザフライカスタムソリューションについては考えていますが、うまく機能しない恐れがありました。 SourceForgeはSVNだけではないのですか?あるいは、彼らはSVNだけをブリッジする独自のソフトウェアを持っていますか? オフラインの解決策はあまりにも多すぎます。恐れがあります。私は望む任意のディレクトリからzipファイルを生成したい。 これを行うことができるSVNに代わる良い方法がある場合は、私は切り替えてうれしいです。 – tofi9

0

TortoiseSVNには、ブラウザが認識するプラグ可能なプロトコルがいくつか登録されています。 svn:// blahblahblah ...あなたはそれを見ることができます。しかし、あなたはTortoiseSVNを使用しなければなりません。

+0

私はこれを知らなかった、それのためにありがとう。しかし、それは私の問題の解決策ではありません。私は実際にWeb経由で提供されるサーバー側のソリューションを探しています。 SourceForge/Codeplexのようにそうする。 – tofi9

関連する問題