Sharpsvnでコミットを行うのに問題があります。これで、作業コピーのすべてのファイルを追加し(ファイルが追加された場合は例外がスローされます)、その後コミットします。動作しますが、例外が発生します。add()を実行する前にリポジトリのステータスを取得し、新しいファイルまたは変更されたファイルのみを追加する方法はありますか?また、作業コピーで1つのファイルまたはフォルダーを削除した場合、リポジトリでこれらのファイルまたはフォルダーを削除するにはどうすればよいですか?コード:
String[] folders;
folders = Directory.GetDirectories(direccionLocal,"*.*", SearchOption.AllDirectories);
foreach (String folder in folders)
{
String[] files;
files = Directory.GetFiles(folder);
foreach (String file in files)
{
if (file.IndexOf("\\.svn") == -1)
{
Add(file, workingcopy);
}
}
}
Commit(workingcopy, "change");
追加:
public bool Add(string path, string direccionlocal)
{
using (SvnClient client = new SvnClient())
{
SvnAddArgs args = new SvnAddArgs();
args.Depth = SvnDepth.Empty;
Console.Out.WriteLine(path);
args.AddParents = true;
try
{
return client.Add(path, args);
}
catch (Exception ex)
{
return false;
}
}
}
専念:
public bool Commit(string path, string message)
{
using (SvnClient client = new SvnClient())
{
SvnCommitArgs args = new SvnCommitArgs();
args.LogMessage = message;
args.ThrowOnError = true;
args.ThrowOnCancel = true;
try
{
return client.Commit(path, args);
}
catch (Exception e)
{
if (e.InnerException != null)
{
throw new Exception(e.InnerException.Message, e);
}
throw e;
}
}
}