我需要知道源代码管理树中特定级别发生了哪些更改(如果有)。有没有办法对TFS进行这样的查询?
答案 0 :(得分:11)
使用团队资源管理器:
显示树中或下方已在该级别签入的所有更改集。
使用tf实用程序:
tf history c:\localFolder -r -format:detailed
以下是tf历史记录文档的链接,了解有关使用的更多详细信息:link
使用TFS SDK以编程方式执行此操作:
这是基于我们的一些代码的示例方法。它需要路径,开始时间和结束时间,并在两个指定时间之间为您提供该路径下的所有变更集详细信息:
private StringBuilder GetTfsModifications(string tfsPath, DateTime startTime, DateTime endTime)
{
StringBuilder bodyContent = new StringBuilder();
TeamFoundationServer tfs = new TeamFoundationServer("YourServerNameHere");
VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
// Get collection of changesets below the given path
System.Collections.IEnumerable changesets = vcs.QueryHistory(
tfsPath,
VersionSpec.Latest,
0,
RecursionType.Full,
null,
new DateVersionSpec(startTime),
new DateVersionSpec(endTime),
int.MaxValue,
true,
false);
// Iterate through changesets and extract any data you want from them
foreach (Changeset changeset in changesets)
{
StringBuilder changes = new StringBuilder();
StringBuilder assocWorkItems = new StringBuilder();
// Create a list of the associated work items for the ChangeSet
foreach (WorkItem assocWorkItem in changeset.WorkItems)
{
assocWorkItems.Append(assocWorkItem.Id.ToString());
}
// Get details from each of the changes in the changeset
foreach (Change change in changeset.Changes)
{
changes.AppendLine(string.Format(CultureInfo.InvariantCulture, "\t{0}\t{1}",
PendingChange.GetLocalizedStringForChangeType(change.ChangeType),
change.Item.ServerItem));
}
// Get some details from the changeset and append the individual change details below it
if (changes.Length > 0)
{
bodyContent.AppendLine(string.Format(CultureInfo.InvariantCulture, "{0}\t{1}\t{2}\t{3}\t{4}",
changeset.ChangesetId,
changeset.Committer.Substring(changeset.Committer.IndexOf('\\') + 1),
changeset.CreationDate,
changeset.Comment,
assocWorkItems.ToString()));
bodyContent.Append(changes.ToString());
}
}
return bodyContent;
}
答案 1 :(得分:1)
如果我理解正确,答案可能很简单:
tf history c:\some\subdir -r -format:detailed -noprompt
如果这还不够好,请回复。