5

I need to be able to programatically lookup code churn info (lines added, changed, deleted) for individual files within a changeset in TFS 2010. The program that I need to do this is in is a desktop client application.

Anyone know how to do this? Do you have sample code you'd like to share?

EVal
  • 93
  • 8

2 Answers2

8

Here is a starting point:

        TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("http://WhateverServerUrl");
        IBuildServer buildServer = (IBuildServer)tfs.GetService(typeof(IBuildServer));
        VersionControlServer VsServer = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
        IBuildDetail build = buildServer.GetAllBuildDetails(new Uri("http://WhateverBuildUrl"));

        List<IChangesetSummary> associatedChangesets = InformationNodeConverters.GetAssociatedChangesets(build);


        foreach (IChangesetSummary changeSetData in associatedChangesets)
        {
            Changeset changeSet = VsServer.GetChangeset(changeSetData.ChangesetId);
            foreach (Change change in changeSet.Changes)
            {
                bool a = change.Item.IsContentDestroyed;
                long b = change.Item.ContentLength;
            }
        } 

Changeset has the following:

    public Change[] Changes { get; set; }
    public int ChangesetId { get; set; }
    public CheckinNote CheckinNote { get; set; }
    public string Comment { get; set; }
    public string Committer { get; set; }
    public DateTime CreationDate { get; set; }
    public string Owner { get; set; }

Change has the following:

    public ChangeType ChangeType { get; }
    public Item Item { get; }
    public ReadOnlyCollection<MergeSource> MergeSources { get; }

Item has the following:

    public Uri ArtifactUri { get; }
    public Uri ArtifactUriLatestItemVersion { get; }
    public int ChangesetId { get; }
    public DateTime CheckinDate { get; }
    public static IComparer Comparer { get; }
    public long ContentLength { get; }
    public int DeletionId { get; }
    public int Encoding { get; }
    public byte[] HashValue { get; }
    public bool IsBranch { get; }
    public bool IsContentDestroyed { get; }
    public int ItemId { get; }
    public Stream DownloadFile();
    public void DownloadFile(string localFileName);
Mike Veigel
  • 3,795
  • 2
  • 20
  • 28
0

If you are willing to use the Cube you can use that to get your code coverage. http://blogs.msdn.com/b/jampick/archive/2010/07/06/tfs-2010-code-churn-report-getting-additional-detail.aspx

user793390
  • 46
  • 3