Commit in sharpSVN
Posted
by Pedro
on Stack Overflow
See other posts from Stack Overflow
or by Pedro
Published on 2010-03-05T11:04:14Z
Indexed on
2010/03/15
10:49 UTC
Read the original article
Hit count: 1325
Hello! I have a problem doing commit with sharpsvn. Now i´m adding all the files of my working copy (if the file is added throws an exception), and after it i do commit. It works but it trows exceptions. There is some way to get the status of the repository before do add() and only add the new files or the files who are changed? And if i delete one file or folder on my working copy , How can i delete these files or folder on the repository? Code:
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");
Add:
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;
}
}
}
Commit:
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;
}
}
}
© Stack Overflow or respective owner