If you have experience with using the SharpSvn .NET library, I could use your expertise in setting the commit author during an SVN commit. I've tried a few things, but they all throw an SvnRepisitoryIOException unless the user is saved in TortoiseSVN. However, I want to use different user credentials depending on the situation. If I've saved a user's default credentials, TortoiseSVN remembers them in Settings > Saved Data > Authenticated Data, and is able to commit a file using that authenticated user as the commit author. If you click "Clear" here, SharpSVN won't know who to authenticate during a commit.
Assume you have these directives in your class: using SharpSvn; using SharpSvn.Security; I'm using the free version of VisualSVN server for Windows. And I have two users, one being named "user1" and password of "pass1" to keep things simple in the examples below that failed.
How can I prevent this exception from being thrown and commit using different users for the author (in my log of the commit)?
Attempt #1:
using (SvnClient client = new SvnClient())
{
client.Authentication.Clear(); // Clear a previous authentication
client.Authentication.DefaultCredentials = new System.Net.NetworkCredential("user1", "pass1");
SvnCommitArgs ca = new SvnCommitArgs();
ca.LogMessage = "svn log message created at " + DateTime.Now.ToString();
bool action = client.Commit(@"C:\demo_repo\demo_project\trunk\file.txt", ca);
}
Attempt #2:
using (SvnClient client = new SvnClient())
{
client.SetProperty(("", "svn:author", "user1");
SvnCommitArgs ca = new SvnCommitArgs();
ca.LogMessage = "svn log message created at " + DateTime.Now.ToString();
bool action = client.Commit(@"C:\demo_repo\demo_project\trunk\file.txt", ca);
}
Attempt #3:
using (SvnClient client = new SvnClient())
{
client.Authentication.Clear(); // Clear predefined handlers
client.Authentication.UserNamePasswordHandlers
+= delegate(object obj, SharpSvn.Security.SvnUserNamePasswordEventArgs args)
{
args.UserName = "user1";
args.Password = "pass1";
};
SvnCommitArgs ca = new SvnCommitArgs();
ca.LogMessage = "svn log message created at " + DateTime.Now.ToString();
bool action = client.Commit(@"C:\demo_repo\demo_project\trunk\file.txt", ca);
}