简体   繁体   中英

Get labels applied to a particular version of an item in TFS source control

I'm trying to get a list of labels that apply to a particular version of a particular file in TFS Source Control. So far, I've gotten a set of labels that apply to any version of a particular file. Does anyone have any experience getting labels for a particular item?

For example, I have $/Project/Folder/Item.cs, which was modified in changesets 301, 401, and 601. Labels Build1 - Build 99 exist for the project. Build1 - Build10 were applied before changeset 301 (ie before Item.cs was created). Build96 - Build99 were applied to the v601 of Item.cs. If I run

vcServer.QueryLabels(null, "$/Project", null, false, "$/Project/Folder/Item.cs", new ChangesetVersionSpec(6)) 

I get Build11 - Build99 as results. I haven't figured out how to get a query to return fewer than this many labels. Ideally, the query I run will return 4 labels (Build96 - Build 99).

The context of this question is a TFS Project, with CCNET for a build server. I'm trying to relate work items to builds, starting with a work item number.

Any tips? Or examples of QueryLabels? Or better docs for QueryLabels than the MSDN docs ?

This is possible, see here: http://social.msdn.microsoft.com/Forums/en-US/tfsversioncontrol/thread/9f41f37e-4fda-4b56-91a3-f2b7e0c0e22d

Basically, once you get back the list of labels, you have to look through each label and see what changeset of the item you're interested in it applies to. Be sure to pass in the "includeItems = false" flag to QueryLabels, otherwise you'll have to look through every item on the label.

What you are wanting to do should definitely be possible using the API. The answer I gave to the other question was about seeing the labels inline with history in the UI.

For more information about doing what I think you are wanting to do, then take a look at:

and also

Hope that helps.

Martin.

当前的 TFS 版本似乎不可能,但下一个版本可能会。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM