5

How do I use SharpSVN to programatically to add a folder to the ignore list?

EDIT: Attempted:
Here's what I've tried

svnClient.GetProperty(new SvnUriTarget("svn://svn.foo.com/" + DatabaseName + "/"), SvnPropertyNames.SvnIgnore, out ignores);
ignores += " Artifacts";
var args = new SvnSetPropertyArgs() { BaseRevision = ???, LogMessage = "update ignore list" };
svnClient.SetProperty(new Uri("svn://svn.foo.com/" + DatabaseName + "/"), SvnPropertyNames.SvnIgnore, ignores, args);

But I don't know how to get the BaseRevision (I can get it manually, and that works, but all the combinations of GetProperty I tried don't seem to give it to me.)

SOLUTION: Based on Bert's Answer

SvnGetPropertyArgs getArgs = new SvnGetPropertyArgs(){};
string ignores = "Artifacts";
string result;
if(svnClient.GetProperty(new SvnUriTarget("svn://svn.foo.com/" + ProjectName + "/trunk/"), SvnPropertyNames.SvnIgnore,out result))
{
    ignores = result + " Artifacts"; //TODO: check for existing & tidy formatting.
}
svnClient.SetProperty(UncPath.TrimEnd('\\'), SvnPropertyNames.SvnIgnore, ignores);
SvnCommit(svnClient);
Myster
  • 17,704
  • 13
  • 64
  • 93
  • You should just retrieve and set the property on your local working copy and then commit the change to the repository. (To do this, just replace the UriTarget with a local path). – Bert Huijben Mar 02 '10 at 12:26
  • Not really related (as local paths are much easier): But instead of using the SvnUriTarget class directly, you can just pas a normal System.Uri instance. There are automatic conversions for string->SvnPathTarget and Uri->SvnUriTarget defined. – Bert Huijben Mar 02 '10 at 12:27

1 Answers1

4

The ignore list is stored in the 'svn:ignores' property on the parent directory that contains the to be ignored file/directory. (See the Subversion book or svn help propset)

So to add an item you have to get the original property value (if one exists) and then add the extra item separated with whitespace. The functions on SvnClient for this are GetProperty and SetProperty().

Bert Huijben
  • 19,525
  • 4
  • 57
  • 73
  • that's helpful, but I'm still missing some details to get it working (see edited question) – Myster Mar 02 '10 at 03:31
  • I don't have a local path, I have a UNC path. If I call 'SetProperty' like so: svnClient.SetProperty("\\\\dev1\\www\\www.automan.foo.com\\", "svn:ignore", " Artifacts"); I get the exception: "'\\dev1\\www' is not a working copy" – Myster Mar 11 '10 at 22:47
  • Not 100% sure, but I think this indicates that the www.automan.foo.com file is not a workingcopy either (probably not even a directory) and you can only set svn:ignore properties on working copy directories. – Bert Huijben Mar 12 '10 at 09:47
  • Ahh got it, I've removed the trailing slash and it works fine. – Myster Mar 16 '10 at 00:10