Search code examples
c#sharpsvn

Problem with commit in sharpsvn


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!!! :)


Solution

  • 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");