0

I am newbie in SharpSVN. I found many examples from Internet related with SharpSVN. Also i did some success cases like Checkout

But the problem is, I can not call commit and Add functions:

The operation that i want to do is Selecting a file from my PC then add to specified SVN folder, also if the file is exist , it should be copied as new version.

Here is my code:

private void button1_Click(object sender, EventArgs e)
{
    // FileUpload1.SaveAs("C:\\Users\\user\\Desktop\\crazycodeee\\" + FileUpload1.FileName);
    SvnClient client = new SvnClient();
    client.Authentication.Clear();
    client.Authentication.DefaultCredentials = new NetworkCredential("crazyufuk", "123456");
    SvnCheckOutArgs coArgs = new SvnCheckOutArgs();
    coArgs.Depth = SvnDepth.Infinity;
    // client.CheckOut(new Uri("http://localhost:8080/svn/crazycode/branches/"), "C:\\Users\\TTVERCIN\\Desktop\\crazycodeee");
    Add("C:\\Users\\user\\Desktop\\test_folderl\\");
    Commit("C:\\Users\\user\\Desktop\\crazycodeee", "AS"); 
}

public bool Add(string path)  
{
    using (SvnClient client = new SvnClient())
    {
        SvnAddArgs args = new SvnAddArgs();
        args.Depth = SvnDepth.Empty;
        args.AddParents = true;
        return client.Add(path, args);
    }
}

public bool Commit(string path, string message)  //second
{
    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;
        }
    }
}
Erhan H.
  • 520
  • 4
  • 14
  • 24

1 Answers1

1

In order to add or commit files to an SVN repository, you'll have to check out the relevant repository locally.

// client.CheckOut(new Uri("http://localhost:8080/svn/crazycode/branches/"), "C:\\Users\\TTVERCIN\\Desktop\\crazycodeee");

The commented out code checks out the code to a repository to this root "C:\\Users\\TTVERCIN\\Desktop\\crazycodeee", but the files you add need to be children of this.

In your line

Add("C:\\Users\\TTVERCIN\\Desktop\\CSI_headerFooterMenu_prepaid_kurumsal\\");

If CSI_headerFootermenu_prepaid_kurumsal where in the crazycodeee folder (and you commented out the checkout line), then I suspect it would work.

Jeff Foster
  • 43,770
  • 11
  • 86
  • 103
  • 2
    The recommended format for the subversion api is not adding the final '\' to paths unless required. But SharpSvn will remove it for you if you add it anyway. (But the paths you get back through notifications, lists, etc. won't have it) – Bert Huijben Sep 06 '12 at 17:11