问题
I want to commit the changes of a working copy in my computer to the repository. The repository is in an URL and i´m doing this now:
using (SvnClient client = new SvnClient())
{
SvnCommitArgs ca = new SvnCommitArgs();
ca.ChangeLists.Add(workingcopydir + filename);
ca.LogMessage = "Change";
client.Add(workingcopydir + filename);
try
{
client.Commit(workingcopydir, ca);
//, ca, out resultado
}
catch (Exception exc)
{
MessageBox.Show(this, exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
But it doesn´t work, when it finish the file is added but not commited. Why? Thanks!!! :)
回答1:
FWIW, I do it like so:
public bool Add (string path)
{
using(SvnClient client = NewSvnClient()){
SvnAddArgs args = new SvnAddArgs();
args.Depth = SvnDepth.Empty;
args.AddParents = true;
return client.Add(path, args);
}
}
public bool Commit (string path, string message)
{
using(SvnClient client = NewSvnClient()){
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;
}
}
}
Then I call it like:
repo.Add("some folder");
...
repo.Commit("base working copy");
回答2:
The ChangeList argument works as a filter. Only files that are marked to be in the specific changelists will be operated upon.
For commit you can just provide multiple targets.
来源:https://stackoverflow.com/questions/2362303/problem-with-commit-in-sharpsvn