获取 TFS 工作区的当前变更集 ID

发布于 2024-12-09 10:38:24 字数 232 浏览 0 评论 0 原文

如何确定本地工作区中当前有哪些变更集?

当然,我可以选择一个文件并查看其历史记录。但是,如果该文件最近没有更新,则其变更集可能比同一解决方案中最近更新的文件更旧。

我们可能犯的一个可能的错误是我们查看解决方案文件的历史记录,但是解决方案文件很少更改,除非您添加新项目/进行解决方案级别的更改。

最后,为了找出变更集,我需要记住最新更改的文件是什么并查看它们的历史记录。

有更好的方法吗?

How do I figure out what changeset I currently have in my local workspace?

Sure, I can pick one file and view its history. However, if that file was not recently updated, its changeset is probably older than the more recently updated files in the same solution.

One possible mistake that we may make is that we view the history on the solution file, however the solution file rarely changes unless you're adding a new project / making solution-level changes.

In the end to figure out the changeset I need to remember what were the latest files changed and view their history.

Is there a better way to do this?

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

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

发布评论

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

评论(5

想挽留 2024-12-16 10:38:24

您的答案位于 Buck Hodges 的 MSDN 博客上:

noreferrer">如何从工作区的根(顶部)

tf history . /r /noprompt /stopafter:1 /version:W

Your answer is on a MSDN blog by Buck Hodges: How to determine the latest changeset in your workspace

from the root (top) of your workspace, in cmd perform:

tf history . /r /noprompt /stopafter:1 /version:W
我纯我任性 2024-12-16 10:38:24

使用 tf.exe 历史记录 的常见答案。 /r 直接可以工作,但速度可能非常慢。在我们的例子中,需要 10-15 秒。
我现在使用两阶段检查,首先检查一些任意文件的修订(我正在使用根文件夹中的文件)。

使用 powershell:

$tfexepath = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe"
$localpath = "C:\some\tfs\directory"
    
$result = & $tfexepath history $localpath /noprompt /stopafter:1 /version:W 
"$result" -match "\d+" | out-null
$id = $matches[0]

然后使用 /r 标志从根开始搜索,但限制搜索从上面找到的修订版本开始:

$result2 = & $tfexepath history $localpath /r /noprompt /stopafter:1 /version:$id~W        
"$result2" -match "\d+" | out-null
$id2 =  $matches[0]

#result:
Write-Host $id2 

对于我们的代码库,这会将总时间从 10-15 减少到 1.4 -1.5秒。

据我了解,没有缺点或限制,但我认为在小型存储库中它可能会更慢。 - 我很高兴知道。

The common answer to use tf.exe history . /r directly does work, but it can be horribly slow. In our case it takes 10-15 seconds.
I now use a two stage check, first checking the revision of some arbitrary files (I'm using the files in the root folder).

With powershell:

$tfexepath = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe"
$localpath = "C:\some\tfs\directory"
    
$result = & $tfexepath history $localpath /noprompt /stopafter:1 /version:W 
"$result" -match "\d+" | out-null
$id = $matches[0]

Then search from the root using the /r flag, but limit the search to start from the revision found above:

$result2 = & $tfexepath history $localpath /r /noprompt /stopafter:1 /version:$id~W        
"$result2" -match "\d+" | out-null
$id2 =  $matches[0]

#result:
Write-Host $id2 

For our code base, this brings down the total time from 10-15 to 1.4-1.5 seconds.

As far as I understand there are no drawbacks or limitations, but I suppose it could be slower in a tiny repository. - I'd be glad to know.

暮年慕年 2024-12-16 10:38:24

运行 Visual Studio CMD(在我的例子中,VS2015 称为:“VS2015 的开发人员命令提示符”),然后进入项目文件夹并执行以下命令:

tf history . /r /noprompt /stopafter:1 /version:W

Run a Visual Studio CMD (in my case, for VS2015 is called: "Developer Command Promp for VS2015") and then get into your project folder and execute the following command:

tf history . /r /noprompt /stopafter:1 /version:W
ヤ经典坏疍 2024-12-16 10:38:24

如果您想使用 PowerShell (另请参阅;相当于@kroonwijk):

  1. 启用 tfs 管理单元(一次,如果还没有的话)

    add-pssnapin Microsoft.TeamFoundation.PowerShell

  2. 使用 tfs cmdlet 获取当前变更集 ID

    Get-TfsItemHistory ; -Recurse -Stopafter 1 -Version W

If you want to use PowerShell (see also; equivalent to answer of @kroonwijk):

  1. enable tfs snapin (once, if not already)

    add-pssnapin Microsoft.TeamFoundation.PowerShell

  2. use tfs cmdlet to get current changeset id

    Get-TfsItemHistory <PATH_TO_PROJECT> -Recurse -Stopafter 1 -Version W

糖粟与秋泊 2024-12-16 10:38:24

如果您确实不知道自己拥有什么版本,则应该使用其他建议的方法之一。如果您只是不确定是否有特定版本,或者不确定几个更改集,并且您更喜欢使用 VS TFS GUI 工作,则可以执行以下步骤:

  1. 选择您想要确定的更改集并进行比较:
    输入图片此处描述
  2. 如果没有区别:
    输入图片此处描述

    或者,如果唯一不同的文件是您有待更改的文件:
    输入图片此处描述

这意味着您已使用相关版本的最新版本。

  1. ** 如果您不确定具有待更改的文件是否实际上也不是最新的,您可以使用属性检查该文件版本:
    输入图片此处描述

If you really have no idea what version you have you should use one of the other suggested methods. If you are just not sure if you have a specific version or you are uncertain between a few change sets and you prefer working from the VS TFS GUI you can fallow this steps:

  1. Pick the change set you want to be certain about and do a compare:
    enter image description here
  2. If you have no difference:
    enter image description here

    or, if the only files that are different are files that you have pending changes in:
    enter image description here

That means you are up to date with the version in question.

  1. ** If you are not sure if file that has a pending change is actually also not up to date you can check that file version with properties:
    enter image description here
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文