English 中文(简体)
How to find all changes below a certain point in the TFS source control tree
原标题:
  • 时间:2009-11-09 16:10:30
  •  标签:
  • 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?

最佳回答

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, "	{0}	{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}	{1}	{2}	{3}	{4}", 
                    changeset.ChangesetId, 
                    changeset.Committer.Substring(changeset.Committer.IndexOf( \ ) + 1), 
                    changeset.CreationDate, 
                    changeset.Comment, 
                    assocWorkItems.ToString()));
            bodyContent.Append(changes.ToString());
        }
    }

    return bodyContent;
}
问题回答

If I understand correctly, the answer could be as simple as:

tf history c:somesubdir -r -format:detailed -noprompt

Reply if that s not good enough.





相关问题
Why not use TFS as a build / CI solution?

Currently our build solution is set up using TFS + MS Build scripts. TFS is also being used as a CI server. I ve seen several posts on this site telling people about other CI solutions. Are there ...

Get files from TFS under Linux [closed]

is there a free (command line) tool for linux which with I can get all files from a TFS-Repository (no Check in / Check out required - only get actual version)?

upgrading tfs 2008 sp1 to use sql server 2008

I have an instance of tfs 2008 supported by sql server 2005. I want to change the sql server machine by doing a restore based move. I also want to change the version of sql server to 2008. I know ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

TFSReg in 2010 Beta 2?

does anybody know what is the equivalent of the TFSReg.exe command-line tool in 2010 Beta 2? I cannot find it anywhere, I searched the entire Program Files tree. Was it renamed? Moved? Replaced by ...

热门标签