3

When I view the history of a file in Visual Studio, I see this:

changeset history tree

I try to retrieve these changes through the API:

var queryParams = new QueryHistoryParameters("$/Project/folder/folder/file.cs", RecursionType.None)
{
    ItemVersion = VersionSpec.Latest,
    DeletionId = 0,
    Author = null,
    VersionStart = null,
    VersionEnd = null,
    MaxResults = Int32.MaxValue,
    IncludeChanges = true,
    SlotMode = false
};

foreach (var h in server.QueryHistory(queryParams))
{
    Console.WriteLine(h.ChangesetId);
}

But in the output I only get the top level changesets where the file is in the current location, not the ones it was moved or branched from:

576909
552480
550006

I've searched all over and everything I read makes it look like I'm calling the right thing but it just isn't working.

Kiquenet
  • 14,494
  • 35
  • 148
  • 243
CTarczon
  • 898
  • 9
  • 19
  • What happens when you change the recursion type? Also what about changing the VersionSpec? Also the Changeset object has a Changes collection. I haven't worked with this in a while so am just going off memory and the docs. – Mike Cheel Jul 18 '14 at 23:23
  • In fact I think you if you want to reproduce this you are going to need to go through the Changes property of each Changset object returned. http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.change.changetype.aspx and http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.changetype.aspx – Mike Cheel Jul 18 '14 at 23:28
  • 1) Changing the recursion type does nothing, I believe that's for finding changes in a directory, not a specific file. What would I change the VersionSpec to? I want the latest. 2) The Changes property contains a single object in all cases, with the values of the Change column above (flags for edit, merge, etc.) – CTarczon Jul 21 '14 at 17:21
  • I never found the solution and moved on. – CTarczon Dec 04 '14 at 21:44

1 Answers1

0

Try the below: 12345 is the changeset number that you need the history for.

 IEnumerable<Change> changes = vcs.GetChangesForChangeset(12345, false, Int32.MaxValue, null, null, true);

    foreach (Change change in changes)
    {
        foreach (var m in change.MergeSources)
        {
            //m.VersionFrom;
            //m.VersionTo;
        }
    }