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?
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.