查找TFS中所有锁定的文件

发布于 2024-07-25 05:29:59 字数 103 浏览 16 评论 0原文

我想查看所有被锁定的文件。 到目前为止,我只发现使用 tf.exe status 并查找带有“!”的任何内容 因为它们不像在 UI 中那样被报告为“锁定、编辑”。 有任何想法吗? 谢谢。

I would like to see all files that are locked. so far, I've only found to use tf.exe status and look for anything with '!' because they are not reported as "lock, edit" as they are in the UI. Any ideas? thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

乖乖公主 2024-08-01 05:29:59

如果您安装了电动工具,那么这是一句简单的话:

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

如果如果您更喜欢 GUI 而不是脚本,请尝试 TFS Sidekicks

If you have the power tools installed, it's a one-liner:

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

If you prefer GUIs to scripts, try TFS Sidekicks.

第七度阳光i 2024-08-01 05:29:59

如果您尝试使用 TFS Sidekicks,但不知道如何使用,可以在“工具”、“Team Foundation Sidekicks”、“Status Sidekick”下找到。 您将需要展开该窗口,但随后您将能够搜索用户名的锁。

If you are trying to use TFS Sidekicks, and can't figure out how, it is under Tools, Team Foundation Sidekicks, Status Sidekick. You will need to expand that window, but you will then be able to search for locks for a username.

疾风者 2024-08-01 05:29:59

我认为使用 tf.exe< 是不可能的/a> 甚至 tfpt.exe(Power Tool 命令行)< /a>. 您需要查看待处理的变更集以查找属于锁定的变更。 您可以使用 Power Tool commandlet 在 powershell 中执行此操作,或者您可以使用以下运行 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);
          }
        }
      }

    }
  }
}

I don't think this is possible using tf.exe or even tfpt.exe (The Power Tool command line). You'll need to look through the pending changesets for changes that are locks. You could do this in powershell using the Power Tool commandlets or you could do it using the following bit of .NET code that exercises the TFS API:

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);
          }
        }
      }

    }
  }
}
如果没有你 2024-08-01 05:29:59

从命令提示符

>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')}

from your command prompt

>powershell

Then from powershell do:

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')}
舂唻埖巳落 2024-08-01 05:29:59

我找到了一个 GUI 选项。

  1. 启动 Visual Studio
  2. 打开文件
  3. 转到源代码管理
  4. 然后工作区
  5. 输入您的凭据
  6. 检查显示远程工作区
  7. 删除所有不需要的工作区

就这么简单:)

I've found a GUI option.

  1. Start Visual Studio
  2. Open file
  3. Go to source control
  4. Then workspaces
  5. Enter your credentials
  6. Check show remote workspaces
  7. Remove all unwanted workspaces

That simple :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文