祥叔学编程

祥叔学编程
随笔 - 43, 文章 - 0, 评论 - 250, 阅读 - 20万
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

TFS二次开发11——标签(Label)

Posted on   祥叔  阅读(1553)  评论(0编辑  收藏  举报

下图是在VS2010里创建Label的界面

 

可以看出创建Label 需要如下参数:Name、Comment、Path、Version 。
下面是代码实现:

复制代码
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;

string tpcURL = "http://127.0.0.1:8080/";
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(tpcURL));
VersionControlServer versionControl = tpc.GetService(typeof(VersionControlServer)) as VersionControlServer;

//创建标签
string labelName = "标签名称";
string labelComment = "标签评论";
string path = "$/CRM/Branches/WeiMovie";
VersionSpec version = VersionSpec.Latest;
var versionControlLabel = new VersionControlLabel(versionControl, labelName, versionControl.AuthorizedUser, path, labelComment);

//Represents one or more files or folders on the local machine or in the repository.
var itemSpec = new ItemSpec(path, RecursionType.Full);
var labelItemSpec = new LabelItemSpec[1];
labelItemSpec[0] = new LabelItemSpec(itemSpec, version, false);
var lb = versionControl.CreateLabel(versionControlLabel, labelItemSpec, LabelChildOption.Merge);
//查询标签
VersionControlLabel[] lbls = versionControl.QueryLabels(null, null, null, true);//查询全部标签
//VersionControlLabel[] lbls = version.QueryLabels(null, null, null, false, path, VersionSpec.Latest);// 查询指定路径的标签
//删除标签
versionControl.DeleteLabel(lbls[0].Name, lbls[0].Scope); 
复制代码

 

努力加载评论中...
点击右上角即可分享
微信分享提示