我知道如何使用命令行命令“tf merge”合并TFS 2010中的更改集。
有没有办法可以在C#中使用代码执行此操作。我想合并特定的变更集(樱桃选择),一次一个。
答案 0 :(得分:7)
如果您正在使用2010或2012 TFS对象模型,那么这大致是如此。如果您有任何问题,请告诉我。
// Get a reference to yourTeam Foundation Server.
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("http://<yourserver>:8080/tfs/<yourcollection> "));
// Get a reference to Version Control.
VersionControlServer versionControl = tpc.GetService<VersionControlServer>();
Workspace workspace = versionControl.GetWorkspace("<local path to your workspace>");
string sourceBranch = "$/<sourceBranch>";
string targetBranch = "$/<targetBranch>";
VersionSpec changesetToMerge = new ChangesetVersionSpec(<your changeset here>);
// actually pend the merge
workspace.Merge(sourceBranch, targetBranch, changesetToMerge, changesetToMerge);
// check in the merge
workspace.CheckIn(workspace.GetPendingChanges(), "your comment");