sharpsvn을 사용하여 커밋하는 데 문제가 있습니다. 이제 작업 복사본의 모든 파일을 추가합니다 (파일이 추가 된 경우 예외가 발생 함). 그리고 나서 커밋합니다. 그것은 작동하지만 예외를 발생시킵니다. add()를 수행하기 전에 리포지토리의 상태를 확인하고 변경된 새 파일이나 파일 만 추가하는 방법이 있습니다. 그리고 작업 카피에서 하나의 파일이나 폴더를 삭제하면 저장소에서이 파일이나 폴더를 어떻게 삭제할 수 있습니까? 코드 :sharpSVN에서 커밋
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;
}
}
}