- using (SvnClient client = new SvnClient())
- {
- //サーバー上のリポジトリ位置の設定
- SvnUriTarget repos = new SvnUriTarget(new Uri("file:///C:/svn_repository/SvnTest/"));
- //クライアントのファイル位置を設定
- SvnPathTarget local = new SvnPathTarget(@"C:\source\subvertionTest");
- //両方の情報を取得
- SvnInfoEventArgs serverInfo;
- SvnInfoEventArgs clientInfo;
- client.GetInfo(repos, out serverInfo);
- client.GetInfo(local, out clientInfo);
- //リビジョンを比較
- if (serverInfo.Revision != clientInfo.Revision)
- {
- SvnUpdateResult ret;
- //クライアントのファイルを最新に更新
- client.Update(@"C:\source\subvertionTest", out ret);
- }
- //ファイルの一覧取得用引数の指定
- SvnListArgs args = new SvnListArgs();
- //リビジョンを指定
- args.Revision = 2;
- //処理結果格納変数を定義
- System.Collections.ObjectModel.Collection<svnlisteventargs> list;
- //一覧の取得を実行
- client.GetList(repos, out list);
- //処理結果の表示
- foreach (var i in list)
- {
- switch (i.Entry.NodeKind)
- {
- case SvnNodeKind.Directory:
- Console.WriteLine("Directory:{0}",i.EntryUri.LocalPath);
- break;
- case SvnNodeKind.File:
- Console.WriteLine("File:{0}",i.EntryUri.LocalPath);
- break;
- }
- }
- }
- </svnlisteventargs>
2010年4月18日日曜日
[C#] SharpSVNを使ってSubversionを操作してみる
SharpSVNはSubvertionの.Net用クライアントライブラリ。
それを使って、ローカルのファイルを更新する処理のメモです。
ざっくりコードを乗せてみます。
登録:
投稿 (Atom)