Implement a faster svn cat with SvnClient
Asked Answered
R

1

3

I'm looking for a faster way to retrieve files from SVN than svn cat in .NET.

Currently I'm running a svn cat process for each revision, but it's extremely slow.

Then I've tried with SvnClient:

    Stream st = Console.OpenStandardOutput();

    SvnWriteArgs wargs = new SvnWriteArgs();

    for (int i = 3140; i < 3155; ++i)
    {
        wargs.Revision = i;

        client.Write(new SvnUriTarget("http://filezilla.svn.sourceforge.net/svnroot/filezilla/FileZilla3/trunk/README"), st, wargs);
    }
    st.Flush();

But each iteration is even slower than svn cat.

Is there a way in SvnClient to "reuse" a previously opened connection to the SVN server so that a multiple cat operation can be run faster?

Redon answered 6/5, 2009 at 11:54 Comment(0)
T
4

You can use the FileVersions command to do this. This fetches one complete file, and all other files using the differences between each revision in a single connection. This should give a nice performance boost.

public void WriteRevisions(SvnTarget target, SvnRevision from, SvnRevision to)
{
    using(SvnClient client = new SvnClient())
    {
        SvnFileVersionsArgs ea = new SvnFileVersionsArgs 
            {
                Start = from,
                End = to
            };

        client.FileVersions(target, ea,
            delegate(object sender2, SvnFileVersionEventArgs e)
                {
                    Debug.WriteLine(e.Revision);
                    e2.WriteTo(...);
                 });
    }
}

This requires a server that supports this feature. I'm not quite sure when it was introduced, but Codeplex running SvnBridge for instance doesn't support it. If I remember correctly the delegate is called only once in that case, in that case you'll have to revert to you first solution. Under normal circumstance the delegate is called for each revision between Start and End.

See method WalkMe (and others) in this testcase to see more details about its usage (Username guest, no password).

Tiphani answered 16/5, 2009 at 9:31 Comment(1)
I know this is very old, but ... I assume the "e2" is a typo, and shoule be "e"? And the link to the test case doesn't work. And it would be nice with sample arguments on the WriteTo() method, instead of just "...".Manuelmanuela

© 2022 - 2024 — McMap. All rights reserved.