我想查看所有被锁定的文件。到目前为止,我只发现可以使用tf.exe状态命令,并查找任何带有 "!" 的内容,因为它们在用户界面中没有被报告为“锁定、编辑”。有什么想法吗?谢谢。
tfstatus . -r -user * | % { $_.pendingchanges } | ? { $_.islock } | select -unique serveritem
如果您更喜欢使用图形用户界面而非脚本,请尝试TFS Sidekicks。
如果您正在尝试使用TFS Sidekicks,但不知道如何使用,它在“工具”下的“Team Foundation Sidekicks”中的“状态Sidekick”选项中。您需要展开该窗口,但然后将能够搜索用户名的锁定。
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);
}
}
}
}
}
}
从你的命令提示符
>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')}
我找到了一个GUI选项。
就这么简单 :)