如何将 P4DIFF 限制为仅 SQL 个文件?
How do I limit a P4DIFF to only SQL files?
我 运行 使用 Server 2008 并通过 Powershell 编写 CMD 行 Diff 脚本。我一切正常(工作,未完成)但我无法弄清楚如何将输出限制为仅 SQL 个文件。差异示例:
p4.exe diff -S -db -dn 251674 251616 > C:\Users\UserName\Documents\Queries\Output2.txt
第一个更改列表是 SQL 唯一更改,因此结果符合我的需要,但第二个更改列表是 SQL 和 C 代码更改的混合。我正在继续完善我的 Diff,但我是 DBA,所以我的重点仅在于 SQL 更改...
您提供的命令行无效("p4 diff" 不将更改列表作为参数,它不使用 -S 标志,并且比较未决的更改,而不是提交的更改),所以根据您的描述,我无法修改它来为您提供一些听起来像您正在尝试做的事情的东西,但是像这样:
p4 diff -dbn ....sql
将使用 "b"(忽略空格)和 "n"(RCS 格式)差异标志在当前目录下打开文件,其名称以“.sql”结尾.
如果您想要在两个提交的更改列表之间对 sql 文件进行差异化处理,那么您需要更像:
p4 diff2 -dbn ....sql@251616 ....sql@251674
我能够通过使用整个 Depot 路径和修订号构建单独的查询来完成我的 SQL 只有 Diff。 还有很大的改进空间(比如解析第一个查询的信息而不是运行所有三个查询)但是我运行没时间了想用它来做今天的报告。如有任何有用的建议,我们将不胜感激!
我开始使用 P4Report 并从文件 table(第 1 和第 2 行)中查询符合我的标准的所有信息,并将其输出到 'Report' 文本文件。这最终导致了我在 Excel 中的报告。
P4报表查询:
select * from files where RIGHT (FILE,9) = 'chema.sql' and TIME > timestampadd(4, -8, now()) and action in ('add', 'edit', 'integrate') order by time;
然后我只查询路径和文件名并将其存储在一个变量中(第 3 和第 4 行)。
P4报表查询:
select file from files where RIGHT (FILE,9) = 'chema.sql' and TIME > timestampadd(4, -8, now()) and action in ('add', 'edit', 'integrate') order by time;
最后我查询了版本号并将其存储在一个变量中(第 7 和 8 行)。
P4报表查询:
select revision from files where RIGHT (FILE,9) = 'chema.sql' and TIME > timestampadd(4, -8, now()) and action in ('add', 'edit', 'integrate') order by time;
然后我使用 foreach 循环创建并执行每个 Perforce 命令行字符串,并将每个字符串的结果附加到“_Diff_Report”文本文件中。
最后,我删除了“_Diff_Report”中的所有选项卡(当我导入 Excel 时,它变得更干净)。
$Rpt = '"C:\Program Files\Perforce\P4Report\p4sql.exe" -d ""~"" -i C:\Users\UserName\documents\Queries\DataQ\_Report.txt > C:\Users\UserName\Documents\Queries\Report.txt'
$out = iex "& $Rpt"
$Cmd1 = '"C:\Program Files\Perforce\P4Report\p4sql.exe" -i C:\Users\UserName\Documents\Queries\DataQ\_Files.txt'
$fil = iex "& $Cmd1"
# Debug
# $fil | Out-File C:\Users\UserName\Documents\Queries\_fil_Debug.txt
$Cmd2 = '"C:\Program Files\Perforce\P4Report\p4sql.exe" -i C:\Users\UserName\Documents\Queries\DataQ\_Revisions.txt'
$rev = iex "& $Cmd2"
# Debug
# $rev | Out-File C:\Users\UserName\Documents\Queries\_Rev_Debug.txt
$dt = Get-Date
$dt | Out-File C:\Users\UserName\Documents\Queries\DataQ\_Diff_Report.txt
$f = $fil
$r = $rev
# Debug
# $r | Out-File C:\Users\UserName\Documents\Queries\_R_variable_Debug.txt
$cnt = 2
foreach ($Change in $f)
{
$revision = $r[$cnt] -1
$Cmd3 = '"C:\Program Files\Perforce\p4" diff2 -db '
$Cmd3 = $Cmd3 + '"'
$Cmd3 = $Cmd3 + $f[$cnt]
$Cmd3 = $Cmd3 + '--'
$Cmd3 = $Cmd3 + $revision
$Cmd3 = $Cmd3 + '"'
$Cmd3 = $Cmd3 + ' ' + '"'
$Cmd3 = $Cmd3 + $f[$cnt]
$Cmd3 = $Cmd3 + '--'
$Cmd3 = $Cmd3 + $r[$cnt]
$Cmd3 = $Cmd3 + '"'
$Cmd3
$Diffs = iex "& $Cmd3"
$Diffs | Out-File C:\Users\UserName\Documents\Queries\DataQ\_Diff_Report.txt -Append
$cnt = $cnt + 1
}
$Content = [IO.File]::ReadAllText("C:\Users\UserName\Documents\Queries\DataQ\_Diff_Report.txt")
$Content = $Content -replace "`t",''
Write-Host $Content
[IO.File]::WriteAllText("C:\Users\UserName\Documents\Queries\Diff_Report.txt", $Content)
我 运行 使用 Server 2008 并通过 Powershell 编写 CMD 行 Diff 脚本。我一切正常(工作,未完成)但我无法弄清楚如何将输出限制为仅 SQL 个文件。差异示例:
p4.exe diff -S -db -dn 251674 251616 > C:\Users\UserName\Documents\Queries\Output2.txt
第一个更改列表是 SQL 唯一更改,因此结果符合我的需要,但第二个更改列表是 SQL 和 C 代码更改的混合。我正在继续完善我的 Diff,但我是 DBA,所以我的重点仅在于 SQL 更改...
您提供的命令行无效("p4 diff" 不将更改列表作为参数,它不使用 -S 标志,并且比较未决的更改,而不是提交的更改),所以根据您的描述,我无法修改它来为您提供一些听起来像您正在尝试做的事情的东西,但是像这样:
p4 diff -dbn ....sql
将使用 "b"(忽略空格)和 "n"(RCS 格式)差异标志在当前目录下打开文件,其名称以“.sql”结尾.
如果您想要在两个提交的更改列表之间对 sql 文件进行差异化处理,那么您需要更像:
p4 diff2 -dbn ....sql@251616 ....sql@251674
我能够通过使用整个 Depot 路径和修订号构建单独的查询来完成我的 SQL 只有 Diff。 还有很大的改进空间(比如解析第一个查询的信息而不是运行所有三个查询)但是我运行没时间了想用它来做今天的报告。如有任何有用的建议,我们将不胜感激!
我开始使用 P4Report 并从文件 table(第 1 和第 2 行)中查询符合我的标准的所有信息,并将其输出到 'Report' 文本文件。这最终导致了我在 Excel 中的报告。
P4报表查询:
select * from files where RIGHT (FILE,9) = 'chema.sql' and TIME > timestampadd(4, -8, now()) and action in ('add', 'edit', 'integrate') order by time;
然后我只查询路径和文件名并将其存储在一个变量中(第 3 和第 4 行)。
P4报表查询:
select file from files where RIGHT (FILE,9) = 'chema.sql' and TIME > timestampadd(4, -8, now()) and action in ('add', 'edit', 'integrate') order by time;
最后我查询了版本号并将其存储在一个变量中(第 7 和 8 行)。
P4报表查询:
select revision from files where RIGHT (FILE,9) = 'chema.sql' and TIME > timestampadd(4, -8, now()) and action in ('add', 'edit', 'integrate') order by time;
然后我使用 foreach 循环创建并执行每个 Perforce 命令行字符串,并将每个字符串的结果附加到“_Diff_Report”文本文件中。
最后,我删除了“_Diff_Report”中的所有选项卡(当我导入 Excel 时,它变得更干净)。
$Rpt = '"C:\Program Files\Perforce\P4Report\p4sql.exe" -d ""~"" -i C:\Users\UserName\documents\Queries\DataQ\_Report.txt > C:\Users\UserName\Documents\Queries\Report.txt'
$out = iex "& $Rpt"
$Cmd1 = '"C:\Program Files\Perforce\P4Report\p4sql.exe" -i C:\Users\UserName\Documents\Queries\DataQ\_Files.txt'
$fil = iex "& $Cmd1"
# Debug
# $fil | Out-File C:\Users\UserName\Documents\Queries\_fil_Debug.txt
$Cmd2 = '"C:\Program Files\Perforce\P4Report\p4sql.exe" -i C:\Users\UserName\Documents\Queries\DataQ\_Revisions.txt'
$rev = iex "& $Cmd2"
# Debug
# $rev | Out-File C:\Users\UserName\Documents\Queries\_Rev_Debug.txt
$dt = Get-Date
$dt | Out-File C:\Users\UserName\Documents\Queries\DataQ\_Diff_Report.txt
$f = $fil
$r = $rev
# Debug
# $r | Out-File C:\Users\UserName\Documents\Queries\_R_variable_Debug.txt
$cnt = 2
foreach ($Change in $f)
{
$revision = $r[$cnt] -1
$Cmd3 = '"C:\Program Files\Perforce\p4" diff2 -db '
$Cmd3 = $Cmd3 + '"'
$Cmd3 = $Cmd3 + $f[$cnt]
$Cmd3 = $Cmd3 + '--'
$Cmd3 = $Cmd3 + $revision
$Cmd3 = $Cmd3 + '"'
$Cmd3 = $Cmd3 + ' ' + '"'
$Cmd3 = $Cmd3 + $f[$cnt]
$Cmd3 = $Cmd3 + '--'
$Cmd3 = $Cmd3 + $r[$cnt]
$Cmd3 = $Cmd3 + '"'
$Cmd3
$Diffs = iex "& $Cmd3"
$Diffs | Out-File C:\Users\UserName\Documents\Queries\DataQ\_Diff_Report.txt -Append
$cnt = $cnt + 1
}
$Content = [IO.File]::ReadAllText("C:\Users\UserName\Documents\Queries\DataQ\_Diff_Report.txt")
$Content = $Content -replace "`t",''
Write-Host $Content
[IO.File]::WriteAllText("C:\Users\UserName\Documents\Queries\Diff_Report.txt", $Content)