如何获取特定团队项目的签入/变更记录的历史记录? [英] How to get history of checkins/changsets for specific Team Project?
问题描述
我正在使用TFS客户端API尝试查询TFS 2010实例. 我需要能够执行以下操作
I'm using the TFS Client API to try and query a TFS 2010 instance. I need to be able to do the following
- 对于指定的团队项目,请说"Project A"
- 获取此项目最近签到的历史记录列表(例如最近50次,或最后一天的列表)
然后可以遍历此列表并获取有关项目的一些元数据(理想情况下为文件和文件夹名称)
Then be able to iterate through this list and get some metadata for the items (file and folder names ideally)
我认为我需要在VersionControlServer类上使用QueryXXX方法,但找不到任何有用的或清晰的示例来了解如何使用此方法.
I think I need to use the QueryXXX methods on the VersionControlServer class, but cannot find any helpful or clear examples on how to use this.
我已经看到有GetLastestChangesetId方法,但是看起来好像不能将其限定于特定的项目或目录.
I have seen there is GetLastestChangesetId method, but this doesn't look like it can be scoped to a specific project or directory.
推荐答案
这很简单:
var tfsUrl = "http://myTfsServer:8080/tfs/defaultcollection";
var sourceControlRootPath = "$/MyTeamProject";
var tfsConnection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsUrl));
var vcs = tfsConnection.GetService<VersionControlServer>();
var changeSets = vcs.QueryHistory(sourceControlRootPath, RecursionType.Full);
foreach (var c in changeSets)
{
var changeSet = vcs.GetChangeset(c.ChangesetId);
foreach (var change in changeSet.Changes)
{
// All sorts of juicy data in here
}
}
这篇关于如何获取特定团队项目的签入/变更记录的历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!