Question

Following the code found here: How to check if file is under source control in SharpSvn?

I'm trying to make a small utility application that will iterate over a designated folder and print out the status of all the files.

    private void btnCheckSVN_Click(object sender, EventArgs e)
    {
        ParseSVNResults(CheckSVN());
    }

    private Collection<SvnStatusEventArgs> CheckSVN()
    {
        string path = @"C:\AMG\trunk\AMC";
        if (!Directory.Exists(path))
            return null;

        DevExpress.Utils.WaitDialogForm wait = new DevExpress.Utils.WaitDialogForm();
        wait.Caption = "Please wait, loading SVN file statuses. This may take a moment.";
        wait.Caption += Environment.NewLine + path;
        wait.Show();

        SvnClient client = new SvnClient();
        SvnStatusArgs sa = new SvnStatusArgs();
        sa.Depth = SvnDepth.Infinity;
        Collection<SvnStatusEventArgs> statuses;

        client.GetStatus(path, sa, out statuses);

        wait.Close();
        return statuses;
    }

    private void ParseSVNResults(Collection<SvnStatusEventArgs> results)
    {
        if (results == null)
            return;

        int modified = 0;
        int unversioned = 0;
        foreach (SvnStatusEventArgs item in results)
        {
            memoEditSVNFiles.Text += item.LocalContentStatus.ToString() + " -- " + item.Path + Environment.NewLine;

            if (item.LocalContentStatus.ToString() == "Modified")
                modified++;
            else if (item.LocalContentStatus.ToString() == "NotVersioned")
                unversioned++;
        }

        memoEditSVNFiles.Text += Environment.NewLine + "Modified: " + modified + Environment.NewLine;
        memoEditSVNFiles.Text += "Not Versioned: " + unversioned + Environment.NewLine;
        memoEditSVNFiles.Text += "Total: " + results.Count;
    }

When the code executes, I get a total of 147 Files & Folders. The actual folder has a few thousand files. Is it possible I'm looking at too many files and SharpSVN just quits after a while?

edit; I just tried creating about 100 text files and putting 30 into 3 folders, then 'nesting' them. So I've got;

C:\AMG\trunk\test which has ~30 files C:\AMG\trunk\test\Folder1 which has ~30 files C:\AMG\trunk\test\Folder1\Sub which has another 30

Without comitting this to the repository, when I run the above code on C:\AMG\trunk\test instead of the given path in my code snippet, the output says 1 total file.

Was it helpful?

Solution

So it turns out the SvnStatusArgs class has a "RetrieveAllEntries" boolean flag that defaults to false.

As the name implies, setting this true returns every file, whether it was modified / unversioned or up to date.

1 extra line in the CheckSVN() method in my original post:

        SvnClient client = new SvnClient();
        SvnStatusArgs sa = new SvnStatusArgs();
        sa.Depth = SvnDepth.Infinity;
        sa.RetrieveAllEntries = true; //the new line
        Collection<SvnStatusEventArgs> statuses;

        client.GetStatus(path, sa, out statuses);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top