c# - TFS 2012 API : How do I get all history for a file including renames and merges?

标签 c# tfs tfs-sdk

当我在 Visual Studio 中查看文件的历史记录时,我看到了:

changeset history tree

我尝试通过 API 检索这些更改:

var queryParams = new QueryHistoryParameters("$/Project/folder/folder/file.cs", RecursionType.None)
{
    ItemVersion = VersionSpec.Latest,
    DeletionId = 0,
    Author = null,
    VersionStart = null,
    VersionEnd = null,
    MaxResults = Int32.MaxValue,
    IncludeChanges = true,
    SlotMode = false
};

foreach (var h in server.QueryHistory(queryParams))
{
    Console.WriteLine(h.ChangesetId);
}

但是在输出中我只得到文件在当前位置的顶级变更集,而不是它被移动或分支的那些:

576909
552480
550006

我到处搜索,我读到的所有内容都让我看起来像是在调用正确的东西,但它就是行不通。

最佳答案

尝试以下操作: 12345 是您需要历史记录的变更集编号。

 IEnumerable<Change> changes = vcs.GetChangesForChangeset(12345, false, Int32.MaxValue, null, null, true);

    foreach (Change change in changes)
    {
        foreach (var m in change.MergeSources)
        {
            //m.VersionFrom;
            //m.VersionTo;
        }
    }

关于c# - TFS 2012 API : How do I get all history for a file including renames and merges?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24835013/

相关文章:

c# - 通过c#获取IP地址(在IPv4值中)

c# - 如何检查 SqlBulkCopy 上的列映射?

c# - 2 台开发计算机,1 个使用 TFS 的 C# 解决方案?

c# - WorkItemCollection 项目访问速度太慢

tfs - 在TFS中使用WorkItemStore.Query指定参数的项目列表

c# - 我的 Asp.Net 空 Web 应用程序项目中缺少 Global.asax 文件

c# - 参数类型不匹配 Transforming anonymous Expression<Func<T,U>> to non anonymous Expression<Func<T,U>>

c# - 在 Visual Studio 中以编程方式查询 Git

tfs - 如何自定义 TFS2010 构建以在日志中打印消息

java - 如何使用TFS SDK获取TFS项目子文件夹