代码之家  ›  专栏  ›  技术社区  ›  TheSean

在TFS中查找所有锁定的文件

  •  18
  • TheSean  · 技术社区  · 17 年前

    5 回复  |  直到 11 年前
        1
  •  20
  •   Richard Berg    17 年前

    如果你有 power tools 安装后,它是一个单衬套:

    tfstatus . -r -user * | % { $_.pendingchanges } | ? { $_.islock } | select -unique serveritem
    

    TFS Sidekicks .

        2
  •  6
  •   beenhazed    14 年前

    如果你正在尝试使用TFS边踢,并且不知道如何,它是在工具之下,Team Foundation SoukKekes,状态副手。您将需要展开该窗口,但随后将能够搜索用户名的锁。

        3
  •  4
  •   Martin Woodward    17 年前

    我认为这是不可能的 tf.exe 甚至 tfpt.exe (The Power Tool command line) . 您需要查看挂起的变更集,以查找属于锁的变更。您可以在powershell中使用 Power Tool commandlets 或者,您也可以使用下面一段练习TFS API的.NET代码:

    using Microsoft.TeamFoundation.Client;
    using Microsoft.TeamFoundation.VersionControl.Client;
    
    namespace TfsApiExample
    {
      class Program
      {
        static void Main(string[] args)
        {
          GetLockedFiles("http://tfsserver:8080","$/TeamProject");
        }
    
        private static void GetLockedFiles(string serverUrl, string serverPath)
        {
          TeamFoundationServer tfs = new TeamFoundationServer(serverUrl);
          VersionControlServer vcServer = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
    
          // Search for pending sets for all users in all 
          // workspaces under the passed path.
          PendingSet[] pendingSets = vcServer.QueryPendingSets(
              new string[] { serverPath }, 
              RecursionType.Full, 
              null, 
              null);
    
          Console.WriteLine(
              "Found {0} pending sets under {1}. Searching for Locks...",
              pendingSets.Length, 
              serverPath);
    
          foreach (PendingSet changeset in pendingSets)
          {
            foreach(PendingChange change in changeset.PendingChanges)
            {
              if (change.IsLock)
              {
                // We have a lock, display details about it.
                Console.WriteLine(
                    "{0} : Locked for {1} by {2}",
                    change.ServerItem, 
                    change.LockLevelName, 
                    changeset.OwnerName);
              }
            }
          }
    
        }
      }
    }
    
        4
  •  3
  •   Doug Coburn    11 年前

    从命令提示符

    >powershell
    

    然后从powershell执行以下操作:

    PS > tf info * -recursive | &{
     begin{
      $out=@{}
      $prefix = "loc"
     }
     process{
      if ($_ -match "Local information"){
       if ($out.Count -gt 0) {
        [pscustomobject]$out
        $out=@{}
        $prefix = "loc"
       }
      } ElseIf ($_ -match "Server information"){
       $prefix = "svr"
      } else {
       $parts = $_.Split(':')
       if ($parts.Length -eq 2){
        $out.Add($prefix + $parts[0].Trim(), $parts[1].Trim())
       }
      }
     }
     end{
      if ($out.Count -gt 0) {
       [pscustomobject]$out
      }
     }
    } | where {!($_.svrLock -eq 'none')}
    
        5
  •  -6
  •   Frédéric Charette    14 年前

    1. 启动Visual Studio
    2. 转到源代码管理
    3. 然后是工作空间
    4. 输入您的凭据
    5. 选中“显示远程工作区”
    6. 删除所有不需要的工作区