Search code examples
c#tfsironpythontfs-sdk

TFS API: Retrieve changesets from main branch using VersionControlServer.QueryHistory


Given: TFS server with m > n changesets in team project X.

I am using TFS API and would like to get the n latest changesets of that branch.

I think I should be using VersionControlServer.QueryHistory, but I don't understand how I can specify that I want all commits from main (default) branch of project X, but none from any other branch or from another team project in the collection.


Solution

  • If you only want changes in $/Project/Some/Path, then that should be the first argument to QueryHistory. For example:

    QueryHistory("$/Project/Some/Path", RecursionType.Full, 5);
    

    Will show the most recent 5 changesets that affected $/Project/Some/Path.