Udostępnij za pośrednictwem


Show all pending changes on the Team Foundation server older than a given age

This came up in the forums and Brian responded with an example showing how to list all pending changes.  This is a slightly modified version to print out the changes older than 2 weeks.

    TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(server);

    VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));

    TimeSpan cutoffAge = TimeSpan.FromDays(14); // 2 weeks

    DateTime cutoffPoint = DateTime.Now - cutoffAge;

    PendingSet[] sets = vcs.GetPendingSets(new String[] { "$/" }, RecursionType.Full);

    Console.WriteLine("{0} total pending set(s)", sets.Length);

    foreach (PendingSet set in sets)

    {

        bool setInfoShown = false;

        foreach (PendingChange pc in set.PendingChanges)

        {

            if (pc.CreationDate < cutoffPoint)

            {

                if (!setInfoShown)

                {

                    setInfoShown = true;

                    Console.WriteLine();

                    Console.WriteLine("Workspace {0};{1} on {2} has {3} total pending change(s)", set.Name, set.OwnerName, set.Computer, set.PendingChanges.Length);

           }

                Console.WriteLine("{0,-20} {1,-10} {2,-16} {3}", pc.FileName, pc.ChangeTypeName, pc.CreationDate, pc.LocalItem);

            }

        }

    }

Comments

  • Anonymous
    August 12, 2006
    I recently had to put together a list of links to code samples.&amp;nbsp; This isn't even close to comprehensive,...

  • Anonymous
    September 28, 2007
    Подсистема контроля версий файлов в TFS позволяет работать из командной строки. Находится эта утилита

  • Anonymous
    September 06, 2008
    I recently had to put together a list of links to code samples. This isn't even close to comprehensive,

  • Anonymous
    June 09, 2009
    PingBack from http://cellulitecreamsite.info/story.php?id=8584