Problem with commit in sharpsvn

血红的双手。 提交于 2019-12-13 01:17:45

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!