如何以编程方式合并 TFS 更改集? [英] How to merge TFS change sets programmatically?

查看:25
本文介绍了如何以编程方式合并 TFS 更改集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何使用命令行命令tf merge"合并 TFS 2010 中的更改集.

I know how to merge a change set in TFS 2010 using the command line command "tf merge".

有什么办法可以在 C# 中用代码做到这一点.我只想合并特定的更改集(樱桃选择),一次一个.

Is there a way I can do this in C# with code. I want to merge specific change sets only (cherry pick), one at a time.

推荐答案

如果您使用 2010 或 2012 TFS 对象模型,这大致是您将如何执行此操作.如果您有任何问题,请告诉我.

This is roughly how you would do it if you were working with the 2010 or 2012 TFS object models. Let me know if you have any questions.

// 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");

这篇关于如何以编程方式合并 TFS 更改集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆