Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find all changes below a certain point in the TFS source control tree

Tags:

tfs

I need to know what changes (if any) have happened at a particular level in our source control tree. Is there some way to make such a query of TFS?

like image 981
Ralph Shillington Avatar asked Nov 09 '09 16:11

Ralph Shillington


People also ask

How do I check my TFS history?

Right-Click If you have the Source Control Explorer or File List open, right-click the file you want to view and select Source Control > View History. Local Toolbar In the File List, select the file(s) you want to view. In the local toolbar of the File List, click , then select View History .

How do I show changeset in Visual Studio?

you can go to the Source Control Explorer in Visual Studio and right-click on your project and select View History . This will show you the list of all changesets made to that project, who made them, the date they were made and any comment added to those changesets.

How do I view pending changes in Visual Studio?

On the View menu, click Other Windows, and then click Pending Changes. The Pending Changes window is displayed. In the Pending Changes window, right-click the element that you want to compare to another version, click Compare and then click, With Workspace Version or With Latest Version.


1 Answers

Using Team Explorer:

  1. Open Source Control Explorer
  2. Navigate to desired source control folder
  3. Right-click and choose View History

Shows you all of the changesets that have been checked in at that level in the tree or below.


Using the tf utility:

tf history c:\localFolder -r -format:detailed

Here's a link to the tf history documentation for more details on usage: link


Using the TFS SDK to do it programatically:

Here's a sample method based on some of our code. It takes a path, start time and end time and gives you all of the changeset details below that path in between the two specified times:

private StringBuilder GetTfsModifications(string tfsPath, DateTime startTime, DateTime endTime)
{
    StringBuilder bodyContent = new StringBuilder();

    TeamFoundationServer tfs = new TeamFoundationServer("YourServerNameHere");
    VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));

    // Get collection of changesets below the given path
    System.Collections.IEnumerable changesets = vcs.QueryHistory(
            tfsPath, 
            VersionSpec.Latest, 
            0, 
            RecursionType.Full, 
            null, 
            new DateVersionSpec(startTime), 
            new DateVersionSpec(endTime), 
            int.MaxValue, 
            true, 
            false);

    // Iterate through changesets and extract any data you want from them
    foreach (Changeset changeset in changesets)
    {
        StringBuilder changes = new StringBuilder();
        StringBuilder assocWorkItems = new StringBuilder();

        // Create a list of the associated work items for the ChangeSet
        foreach (WorkItem assocWorkItem in changeset.WorkItems)
        {
            assocWorkItems.Append(assocWorkItem.Id.ToString());
        }

        // Get details from each of the changes in the changeset
        foreach (Change change in changeset.Changes)
        {
            changes.AppendLine(string.Format(CultureInfo.InvariantCulture, "\t{0}\t{1}", 
                    PendingChange.GetLocalizedStringForChangeType(change.ChangeType), 
                    change.Item.ServerItem));
        }

        // Get some details from the changeset and append the individual change details below it
        if (changes.Length > 0)
        {
            bodyContent.AppendLine(string.Format(CultureInfo.InvariantCulture, "{0}\t{1}\t{2}\t{3}\t{4}", 
                    changeset.ChangesetId, 
                    changeset.Committer.Substring(changeset.Committer.IndexOf('\\') + 1), 
                    changeset.CreationDate, 
                    changeset.Comment, 
                    assocWorkItems.ToString()));
            bodyContent.Append(changes.ToString());
        }
    }

    return bodyContent;
}
like image 103
brett rogers Avatar answered Sep 29 '22 10:09

brett rogers