tags:

views:

309

answers:

1

I was hoping that I could pass a DateVersionSpec into VersionControlServer.DownloadFile() but it doesn't work. It tells me that the item doesn't exist at that version, even though the file existed in source on the date passed.

Do I need to query the Item history just so I can figure out what version the file was at on the date in question? Use QueryHistory(...) method?

My current code:

version = new DateVersionSpec(date);
var changeSets = this.vcServer.QueryHistory(remoteFile, VersionSpec.Latest, 0,      
    RecursionType.None, user, version, version, 50, true, false);
if (changeSets == null) 
{
throw new Exception("Failed to find..."); 
}

foreach (var item in changeSets)
 {

 }

Currently I'm not getting anything back when I pull the changeSets enumerable.

I'm using code that's a lot like this: http://blogs.microsoft.co.il/blogs/srlteam/archive/2009/06/14/how-to-get-a-file-history-in-tfs-source-control-using-code.aspx

Update: the code that I have is pretty close (practically identical to the code from the post) but it dies if the file was added on a date before the date passed in and hasn't been changed since i.e. it only has one change and that's an add.

+1  A: 

This got me what I was looking for on my app. If it doesn't work check to make sure your file path is correct. That's what I had wrong the first time around.

this.vcServer.GetItem(remoteFile, new DateVersionSpec(date));
Ryan