1

I am having an issue with the SharpSVN api. When I try to use SvnClient.Write() or SvnClient.Export(), the following error occurs:

Malformed URL for repository

My code is the following

using(SvnClient client = new SvnClient())
        {
            MemoryStream ms = new MemoryStream();
            client.Authenticator.DefaultCredentials = new NetworkCredential("master","master");
            SvnTarget t1 = new SvnUriTarget(new Uri("http://ETAB-APP:81/repositorio/"));
            SvnTarget t2 = new SvnUriTarget(new Uri("http://ETAB-APP:81/repositorio/Registro e Controle Acadêmico/Administração/0000/Dossiê do Aluno - ADEMIR JOSPE SANGALLI - (2001193) - Curso (000)/DOC ADICIONAL(264839).pdf"));

            client.Write(t2, ms);
            client.Export(t2, "C:\\chups");


        }

It's driving me insane because if I try to execute this method using t1 as SvnTarget, everything works fine. But the problem is that I can't export all the repository everytime I want to get an especific file.

I tried to put an "@" before the name of URL i.e.

http://@ETAB-APP:81/repositorio/Registro e Controle Acadêmico/Administração/0000/Dossiê do Aluno - ADEMIR JOSPE SANGALLI - (2001193) - Curso (000)/DOC ADICIONAL(264839).pdf

but nothing happens.

What am I doing wrong?

PS: Sorry if I did any mistake, I am brazilian and my english is not very good

Guilhermevrs
  • 2,094
  • 15
  • 15

2 Answers2

0

when I call sharpsvn to get svn info by url (that contains '&',and end of '/').sharp svn throw an exception.

thanks sbrogers :

Do you need to escape the url? The SVN Api may do it for you, but it might be worth trying running it through msdn.microsoft.com/en-us/library/… – sbrogers Dec 29 '10 at 14:05

I use this code

SvnUriTarget repos = new SvnUriTarget(myUrlString.TrimEnd(new char[] { '/' }));

my problem is resolved.

CRABOLO
  • 8,605
  • 39
  • 41
  • 68
rhinoceros.xn
  • 803
  • 9
  • 12
  • the answer that I write yesterday is wrong. SvnTarget t2 = new SvnUriTarget(YouLongURI.ToString().TrimEnd(new char[] { '/' }) – rhinoceros.xn Jan 20 '13 at 05:53
0

What I have found is that if you simply pass an arbitrary URL to the Uri object constructor, it will create an invalid Uri that SVN does not understand. This can be due to foreign characters or escaping of certain characters that does not need to be escaped by the default Uri object constructor.

Break up the Uri into its parts by using the UriBuilder object and then pass the resulting Uri to SVN.

// Build Uri by explicitly specifying the constituent parts. 
UriBuilder uriBuilder = new UriBuilder("http", "ETAB-APP", 81, "/repositorio/Registro e Controle Acadêmico/Administração/0000/Dossiê do Aluno - ADEMIR JOSPE SANGALLI - (2001193) - Curso (000)/DOC ADICIONAL(264839).pdf");

using(SvnClient client = new SvnClient())
{
    MemoryStream ms = new MemoryStream();
    client.Authenticator.DefaultCredentials = new NetworkCredential("master","master");
    SvnTarget t2 = new SvnUriTarget(uriBuilder.Uri);
    client.Write(t2, ms);
    client.Export(t2, "C:\\chups");
}
Dodgyrabbit
  • 3,107
  • 3
  • 26
  • 28