This all depends on how you connect to your repository, as the repository is responsible for adding a username to the revision. (It usually copies the credentials for the connections but it doesn't have to do that).
When you use a file:/// repository (which is usually not recommended - See The Subversion Book) you can work around this directly on the commit.
using (SvnClient client = new SvnClient())
{
client.Authentication.Clear(); // Clear predefined handlers
// Install a custom username handler
client.Authentication.UserNameHandlers +=
delegate(object sender, SvnUserNameEventArgs e)
{
e.UserName = "MyName";
};
SvnCommitArgs ca = new SvnCommitArgs { LogMessage = "Hello" }
client.Commit(dir, ca);
}
If you connect to a remote repository you can change the author of a revision when a pre-revprop-change hook is installed in the repository (See The Subversion Book)
using (SvnClient client = new SvnClient())
{
client.SetRevisionProperty(new Uri("http://my/repository"), 12345,
SvnPropertyNames.SvnAuthor,
"MyName");
// Older SharpSvn releases allowed only the now obsolete syntax
client.SetRevisionProperty(
new SvnUriTarget(new Uri("http://my/repository"), 12345),
SvnPropertyNames.SvnAuthor,
"MyName");
}
[2009-08-14]
More recent SharpSvn releases also allow this:
using (SvnRepositoryClient rc = new SvnRepositoryClient())
{
SvnSetRevisionPropertyRepositoryArgs ra;
ra.CallPreRevPropChangeHook = false;
ra.CallPostRevPropChangeHook = false;
rc.SetRevisionProperty(@"C:\Path\To\Repository", 12345,
SvnPropertyNames.SvnAuthor, "MyName", ra);
}
This last example assumes direct file access to the repository, but it bypasses repository hooks for optimal performance.