VersionControlServer - Get latest version of file at a specific date/time

六眼飞鱼酱① 提交于 2019-12-11 18:40:04

问题


I have a program gets the latest version of files from a TFS server using the following code.

TeamFoundationServer myTFS = TeamFoundationServerFactory.GetServer(myURL);
VersionControlServer myVCS = (VersionControlServer)myTFS .GetService(typeof(VersionControlServer));

ItemSet downloadItems = myVCS.GetItems(myDirectory, RecursionType.Full);
foreach (Item item in downloadItems.Items)
{
    item.DownloadFile(myDownloadPath);
}

Instead of getting the latest version, I would like to be able to specify a date and time, and get the ItemSet of items at that point in time. Then, on the DownloadFile call, I want to get whatever was the latest version of the files in the ItemSet at the specified date and time.

I see that Item has a CheckinDate property, but if this value is after the date and time that I am looking for, I am not sure how to get the previous version.


回答1:


When you query items with GetItems, you should provide the version spec you're interested in, in this case a DateVersionSpec.

For example:

DateTime whenever = DateTime.Now;
ItemSet downloadItems = myVCS.GetItems(myDirectory, new DateVersionSpec(whenever), RecursionType.Full);

Obviously replacing DateTime.Now with whatever you're interested in.



来源:https://stackoverflow.com/questions/15931114/versioncontrolserver-get-latest-version-of-file-at-a-specific-date-time

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