Matt Burke
Matt Burke

Reputation: 3326

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 (i.e. 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?

Upvotes: 2

Views: 3069

Answers (3)

Martin Woodward
Martin Woodward

Reputation: 11770

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.

Upvotes: 1

TinyGrasshopper
TinyGrasshopper

Reputation: 21

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.

Upvotes: 2

Matt Burke
Matt Burke

Reputation: 3326

It looks like it's not possible with the current TFS version, but may be with the next.

Upvotes: 0

Related Questions