tfstfvc

how to group resources involved in a specific set of changesets?


How can I query the tfs history to have this result: group the resources involved in a set of changesets?

What I'm trying to do is understanding which files changed in the last 2 months for example.

I tried on TFS Explorer, but I can obtain the details just from a single changeset. It's the same for TFS Sidekicks. I had no luck with the command line and not even connecting directly to the database.

Does someone knows a smart way to get that result?


Solution

  • I am not sure how to get the VersionTo and VersionFrom so I am just doing from version 100 to Latest in here. You could you Source Control Explorer to do a View History and get your VersionFrom and VersionTo.

    Here's a snippet of code that uses the TFS API. You will need to add some references to Microsoft.TeamFoundation.* assemblies to get it to build.

    using (var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(CollectionAddress)))
    {
        var server = tfs.GetService<VersionControlServer>();
    
        var changes = 
            server.QueryHistory(
              "$/Project/Main",
              VersionSpec.Latest,
              0,
              RecursionType.Full,
              "",
              VersionSpec.ParseSingleSpec("100", ""), //From ??
              VersionSpec.Latest,                     //To ??
              100,
              true,
              true)
        .Cast<Changeset>()
        .SelectMany(changeset => changeset.Changes.Select(change => change.Item.ServerItem));
    }