【问题标题】:How to get the History of the sourcecontrol in TFS API?如何在 TFS API 中获取源控制的历史记录?
【发布时间】:2013-07-03 20:22:46
【问题描述】:

我是使用 TFS API 的新手,我正在编写一个删除我的团队项目的应用程序,但在我删除之前我想知道最后一次合并我的意思是出现在源代码管理资源管理器中的信息 >“示例Project" > 查看历史,并放入文本框。

还有用户最后一次进入项目的信息。

【问题讨论】:

    标签: .net visual-studio tfs tfs-sdk


    【解决方案1】:

    我不知道如何检查用户上次连接到项目的时间,但这是您可以从代码访问源代码控制历史记录的方式,

    using Microsoft.TeamFoundation.Client; 
    using Microsoft.TeamFoundation.VersionControl.Client;
    using System.Collections;
    using System.Windows.Forms;
    
    //The example function is very simple: It gets a change and shows message boxes of all the changesets that have a change for the specified file up to the change transferred to the method.
    
    //Note: Change the [Server Name] with your TFS name.
    
        public void GetChangesetsOfFile(Change theChange)
        {  
          //Query History parameters
    
          TeamFoundationServer tfs = new TeamFoundationServer 
                        ("[Server Name]");
    
          VersionControlServer VCServer = 
                        (VersionControlServer)tfs.GetService 
                        (typeof(VersionControlServer)); 
    
          int changeId = (theChange.Item.DeletionId != 0) ? 
                        theChange.Item.ChangesetId - 1 :  
                         theChange.Item.ChangesetId;
    
          ChangesetVersionSpec version = new  
                                ChangesetVersionSpec(changeId);
          ChangesetVersionSpec versionFrom = new 
                                ChangesetVersionSpec(1);
          string path = theChange.Item.ServerItem;
    
          //Query History Command
          IEnumerable changesets = VCServer.QueryHistory(path, 
                   version, 0, RecursionType.None, null, 
                   versionFrom, LatestVersionSpec.Latest, 
                   int.MaxValue, true, false);
    
    
          foreach (Changeset cSet in changesets) 
          { 
            MessageBox.Show(cSet.Changes 
                [0].Item.ChangesetId.ToString()); 
          } 
        }
    

    参考

    http://blogs.microsoft.co.il/blogs/srlteam/archive/2009/06/14/how-to-get-a-file-history-in-tfs-source-control-using-code.aspx

    【讨论】:

      【解决方案2】:

      (我假设您指的是 TFS 2012)

      2013 年 MSDN 杂志上有一篇文章应该会给你一个不错的起点 - http://msdn.microsoft.com/en-us/magazine/jj883959.aspx

      顺便说一句,如果您想删除团队项目,我强烈建议您使用 TFSDeleteProject (http://msdn.microsoft.com/en-us/library/ms181482.aspx),因为您将使用受支持的工具。

      【讨论】:

        猜你喜欢
        • 2019-08-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-02-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多