我需要知道在源代碼樹中的特定級別發生了哪些更改(如果有)。有什麼方法可以對TFS進行這樣的查詢嗎?如果這還不夠好如何在TFS源代碼樹中的特定點下找到所有更改
tf history c:\some\subdir -r -format:detailed -noprompt
回覆:
我需要知道在源代碼樹中的特定級別發生了哪些更改(如果有)。有什麼方法可以對TFS進行這樣的查詢嗎?如果這還不夠好如何在TFS源代碼樹中的特定點下找到所有更改
tf history c:\some\subdir -r -format:detailed -noprompt
回覆:
使用團隊資源管理器:
顯示所有的已在樹或更低級別中檢入該級別的變更集。
使用TF實用程序:
tf history c:\localFolder -r -format:detailed
下面是關於使用到TF歷史文檔的鏈接瞭解詳情:link
使用TFS SDK到做它programatical ly:
下面是基於我們的一些代碼的示例方法。它需要一個路徑,開始時間和結束時間,並給你所有的變更細節,下面的路徑在兩個指定時間之間:你想以編程方式做到這一點
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;
}
如果我理解正確的話,答案可能是那樣簡單。
嗎? – 2009-11-09 16:27:49