TFS client C# API - get all changesets of an Item

馋奶兔 提交于 2019-12-01 11:30:54

问题


Microsoft TFS client for VS 2010:

http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.item(v=vs.100).aspx

  • I (i.e., my code) have a Changeset.
  • I iterate to a particular Change.
  • I have an Item in the Change.

Now, I wish to get all Changesets that had Changes for that item.

Could someone advise me the best way to do that?

I could iterate thro all the Changesets of the branch concerned, which would be very inefficient.


回答1:


Edward is correct. And he has the credentials to back it up. (See his profile description) VersionControlServer.QueryHistory is the method you need to use. There are several ways to use it and I'm only describing one below which assumes that the server path of that item is what is important to you...

First, you need the server path of the Item:

string serverPath = Item.ServerItem;

Next, if you don't already have a VersionControlServer object instantiated, you can get one from your TeamProject like this:

VersionControlServer VCServer = (VersionControlServer)this.TeamProject.Store.TeamProjectCollection.GetService(typeof(VersionControlServer));

Use the VersionControlServer QueryHistory(string, boolean) method to get other changesets associated with that server path:

VCServer.QueryHistory(serverPath, false);


来源:https://stackoverflow.com/questions/18854932/tfs-client-c-sharp-api-get-all-changesets-of-an-item

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!