2

Question Background:

I am using the TFS api to query against a large range(1-600+) of files on my TFS server.

From each file I am collecting all of its ChangesetId's which are then collected in a list.

The code:

This is the code I'm using. It works correctly producing an IEnumerable change set list of all the items for the specified parameters in the QueryHistory method.

        VersionSpec versionFrom = VersionSpec.ParseSingleSpec("C1", null);

        VersionSpec versionTo = VersionSpec.Latest;

        var changesetList = tfsDevItem.VersionControlServer.QueryHistory(tfsDevItem.ServerItem, VersionSpec.Latest, 0, RecursionType.None, null, versionFrom, versionTo, Int32.MaxValue, true, false);

        item.VersionList = new List<int>();

        //*****Very slow iteration*****
        foreach (Changeset ChangesetId in changesetList)
        {
            item.VersionList.Add(ChangesetId.ChangesetId);
        }

The Issue:

When looping through each changeset in the chagesetList of the foreach, the time this is taking is incredibly long. For instance 115 files takes 1 minute to produce a list of each individual files changesetID's.

Can I improve this? If so how?

user1352057
  • 3,162
  • 9
  • 51
  • 117

1 Answers1

0

The problem it takes so long is the "True" in your code:

var changesetList = tfsDevItem.VersionControlServer.QueryHistory(tfsDevItem.ServerItem, VersionSpec.Latest, 0, RecursionType.None, null, versionFrom, versionTo, Int32.MaxValue, true, false);

You only need the changeset number, so pass "false" there.

The parameter is repsonsible for filling the "Changes" property of a Changeset. Those Changes are holding MergeSources and ChangeType and so on.

Scordo
  • 1,041
  • 7
  • 12
  • This answer would be better if you expanded on what that variable represented and why changing it would be more efficient. – Edward Thomson Apr 17 '14 at 06:30
  • Added the details to the answer – Scordo Apr 17 '14 at 06:37
  • 1
    @Scordo Thanks for your great answer. Interestingly enough I actually tried that before asking this question. The speed still seem to be as slow with that parameter set false. I will have to try it again to confirm this. – user1352057 Apr 20 '14 at 13:04