Pergunta

I'm using SharpSvn.1.7-x64.1.7010.2403 (provided by NuGet) in a .NET 4.0 Console project. The svn list command is used by me frequently:

Collection<SvnListEventArgs> list;
client.GetList(new SvnUriTarget("https://dev:8443/svn/test/"), out list);
Console.WriteLine("Name            |Path            |Uri                                       |RepositoryRoot");
Console.WriteLine("-------------------------------------------------------------------------------------------------------");
foreach (var item in list)
    Console.WriteLine("{0,-16}|{1,-16}|{2,-42}|{3,-20}", item.Name, item.Path, item.Uri, item.RepositoryRoot);

That outputs the following:

Name            |Path            |Uri                                       |RepositoryRoot
-------------------------------------------------------------------------------------------------------
                |                |https://dev:8443/svn/test/                |https://dev:8443/svn/test/
IAmImportant.txt|IAmImportant.txt|https://dev:8443/svn/test/IAmImportant.txt|https://dev:8443/svn/test/
Properties.txt  |Properties.txt  |https://dev:8443/svn/test/Properties.txt  |https://dev:8443/svn/test/
sub             |sub             |https://dev:8443/svn/test/sub/            |https://dev:8443/svn/test/

Lately I discovered the following mysterious behavior: Using a revision filter I get no Uri anymore :-(

client.GetList(new SvnUriTarget("https://DEV:8443/svn/test/"), new SvnListArgs { Revision = SvnRevision.Head }, out list);

Output:

Name            |Path            |Uri                                       |RepositoryRoot
-------------------------------------------------------------------------------------------------------
                |                |                                          |
IAmImportant.txt|IAmImportant.txt|                                          |
Properties.txt  |Properties.txt  |                                          |
sub             |sub             |                                          |

Is that a bug? If it's not a bug can anyone explain why? How to workaround (hopefully without calling svn info on each item)?

Foi útil?

Solução

The .RepositoryRoot value is not really provided by the Subversion api. SharpSvn knows that in most cases it can be calculated from the first output value of the list argument, except in this specific situation where you pass an operative revision.

Note the difference between svn list URL -r 123 and svn list URL@123. The first looks at URL as it is known in the head revision and traces its origin back to revision 123 in which it might have existed under a different name. The second one checks what was at URL in revision 123. (When in doubt, you most likely want the second form... See the subversion book for details)

This second form is handled as SvnClient.List(new SvnUriTarget(uri, pegrev), ...) and there the calculation works.

The Uri is then formed by combining the knowledge from RepositoryRoot and Path. (You could do all this yourself if you have the RepositoryRoot somewhere. But retrieving this value without outside knowledge is quite a performance hit. That is the reason SharpSvn provides it only in case it already has the knowledge)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top