Question

I am writing some C# code to perform multiple commits to SVN in one pass, much like the tool svnmucc. So far I've been using SharpSvn to do the rest of the necessary communication with SVN, so I'm thinking I can take advantage of it to accomplish the following:

How can I get the credentials (username, password) that are used by SharpSvn?

I'd like to do something like this:

using (SvnClient svnClient = new SvnClient())
{
    SomeFictitiousCredentialsClass credentials = svnClient.Authentication.FictitiousGetCachedCredentialsMethod();

    // Call my code that performs svnmucc-like work here, passing username and password
    // obtained from 'credentials' variable.
}
Was it helpful?

Solution

Sharpsvn doesn't have an api that provides you the credentials from Subversion. It mostly implements the libsvn_client api, and at this level there is no access to this data.

SharpSvn gets a callback from the subversion libraries when these need credentials; in most cases after the builtin password store fails to authenticate.

If your svnmucc code also uses the Subversion apis, you can just plugin the subversion predefined authentication handlers..

SharpSvn itself doesn't have svnmucc support yet. (There was some talk about somebody who liked to add this to SharpSvn, but I haven't got any news about this lately)

OTHER TIPS

While the other answer is still valid for all current versions of SharpSvn, SvnMucc support has just landed in the development code for SharpSvn. So soon it will be possible to perform SvnMucc like operations from .Net.

using SharpSvn;

SvnCommitResult cr;
using (SvnMultiCommandClient mucc = new SvnMultiCommandClient("http://my-repos/svn/"))
{
    mucc.CreateDirectory("trunk");
    mucc.CreateDirectory("branches");
    mucc.CreateDirectory("tags");
    mucc.CreateDirectory("trunk/src");
    mucc.SetProperty("", "svn:auto-props", "*.cs = svn:eol-style=native");
    mucc.SetProperty("", "svn:global-ignores", "bin obj");

    mucc.Commit(out cr); // Commit r1
}
using (SvnClient client = new SvnClient())
{
   client.CheckOut("http://my-repos/svn/", @"C:\wc");
}

There is a slightly different syntax available if you would like to perform the operation from an existing SvnClient, but this is the general idea.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top