解释 tf diff

发布于 2024-08-19 12:28:58 字数 991 浏览 5 评论 0原文

使用 Visual Studio 2008 工具,

我尝试获取更改集 14318 和 14317 的 ASCII 差异。

我可以使用 GUI 来执行此操作:

tf changeset 14318

然后选择一个文件并右键单击并选择与以前的版本进行比较。然而,这有点乏味,而且它是基于 GUI 的。我手头的任务是将许多更改向后移植到不同的分支中。我想自动化测试(比如使用Python),确保我做得正确。好吧,出于教育目的,我将手动进行所有更改,而不查看解决方案,然后我将比较这两个更改并尝试查找任何差异。这就是我喜欢 tf 的地方 - 我可以输入:

tf changeset 14318 > out.txt&&notepad out.txt

查看受影响文件的详细信息。

同样,我希望获得一个 out.txt,其中保存了所有差异。我很确定我可以处理 Python 部分。我绝对想知道如何使用 tf.exe 工具来完成此操作,但如果您还碰巧知道完成此操作的其他技巧(一些很酷的第 3 方工具或 PowerShell 脚本,那么也请让我知道)。

谢谢你!

哦,顺便说一下,我检查了这个: http:// msdn.microsoft.com/en-us/library/6fd7dc73(VS.80).aspx

我尝试了以下操作:

tf diff 14318 14317

我收到此错误: 文件(或文件夹)c:\Program Files (x86)\ Microsoft Visual Studio 9.0\VC\14318 不存在。

现在谢谢你。

编辑:有没有任何工具可以做到这一点?

Using Visual Studio 2008 tools,

I am trying to get an ASCII diff of change sets 14318 and 14317.

I can do so using GUI:

tf changeset 14318

and then select a file and right-click and select compare with previous version. However, this is a bit tedious and it is GUI-based. My task at hand is to back-port many changes into a different branch. I would like to automate the testing (say using Python), making sure that I did it correctly. Well, for educational purposes I will make all changes by hand without looking at the solution, and then I will compare the two changes and try to look for any differences. Here is what I love about tf - I can type:

tf changeset 14318 > out.txt&¬epad out.txt

to view the details of what files were affected.

Similarly, I wish to get an out.txt with all the differences saved in it. I am pretty sure that I can handle the Python part. I definitely want to know how to do it using the tf.exe tool, but if you also happened to know other tricks for accomplishing this (some cool 3rd party tool, or PowerShell script, then please let me know as well).

Thank you!

Oh, by the way, I checked this: http://msdn.microsoft.com/en-us/library/6fd7dc73(VS.80).aspx

And I tried this:

tf diff 14318 14317

And I have gotten this error: File (or folder) c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\14318 does not exist.

Now thank you.

EDIT: Are there any tools at all that can do this?

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

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

发布评论

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

评论(2

じ违心 2024-08-26 12:28:58

您只是在调用它时没有使用正确的语法。在本例中,它尝试在您的工作副本与(不存在的)文件 1431814317 的基本存储库版本之间进行比较。

您需要做的是在 /version 中使用变更集范围,如下所示:

tf diff $/Foo /version:C14317~C14318 /recursive /format:unified > foo.diff

请注意,您可以将 ~ 与任何其他版本规范 - 标签、日期等一起使用。有关详细信息,请参阅此处

You're just not using the correct syntax when calling it. In this case, it tried to do a diff between your working copy, and the base repository version, of (non-existing) files 14318 and 14317.

What you need to do instead is to use a changeset range in /version, like this:

tf diff $/Foo /version:C14317~C14318 /recursive /format:unified > foo.diff

Note that you can use ~ with any other version specs - labels, dates etc. See here for details.

甜`诱少女 2024-08-26 12:28:58

这是一个 PowerShell (V2) 脚本,扩展自 Pavel 的答案,这将提高性能,因为我们找到已更改的文件,然后使用 tf 单独比较它们:

Write-Host "Checking if TFS snap-in has been added..." -ForegroundColor green

# Find all TFS snapins.
$snapins = Get-PSSnapin -Registered | Where-Object { $_.Name -like "*TeamFoundation*" } 

foreach($snapin in $snapins)
{ 
    # Add snapin if not already added.
    $exists = Get-PSSnapin | Where-Object { $_.Name -eq $snapin.Name } 
    if (!$exists)
    {
        Write-Host "Adding Snapin " $snapin.Name -ForegroundColor green 
        Add-PSSnapin $snapin.Name 
    }
    else
    {
        Write-Host "Snapin already added." -ForegroundColor green
    }
}



# Get TFS Server object reference.
$tfs_server = Get-TfsServer -Name $/<serverName>/<RepoDir>

# Get list of changed files 
$changes_from_changeset = Get-TfsChangeset -ChangesetNumber 829 | Select -Expand Changes | % { $_.Item.ServerItem }
#$changes_from_changeset

foreach($change in $changes_from_changeset)
{
    &"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe" diff $change /version:829~T /format:unified
}

Here is a PowerShell (V2) script, extending from Pavel's answer, this will be more performant, because we find the files that have changed, then get tf to diff them individually:

Write-Host "Checking if TFS snap-in has been added..." -ForegroundColor green

# Find all TFS snapins.
$snapins = Get-PSSnapin -Registered | Where-Object { $_.Name -like "*TeamFoundation*" } 

foreach($snapin in $snapins)
{ 
    # Add snapin if not already added.
    $exists = Get-PSSnapin | Where-Object { $_.Name -eq $snapin.Name } 
    if (!$exists)
    {
        Write-Host "Adding Snapin " $snapin.Name -ForegroundColor green 
        Add-PSSnapin $snapin.Name 
    }
    else
    {
        Write-Host "Snapin already added." -ForegroundColor green
    }
}



# Get TFS Server object reference.
$tfs_server = Get-TfsServer -Name $/<serverName>/<RepoDir>

# Get list of changed files 
$changes_from_changeset = Get-TfsChangeset -ChangesetNumber 829 | Select -Expand Changes | % { $_.Item.ServerItem }
#$changes_from_changeset

foreach($change in $changes_from_changeset)
{
    &"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe" diff $change /version:829~T /format:unified
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文