2
有没有一种简单的方法来找到一个特定文件存在的svn仓库中的所有路径(标签和分支)?如何在svn中查找一个文件的所有副本?
我知道在trunk上检查了文件的修订版本,当它被删除时,我需要在这两个修订版本之间找到所有分支,标签和可能的其他路径副本。
有没有一种简单的方法来找到一个特定文件存在的svn仓库中的所有路径(标签和分支)?如何在svn中查找一个文件的所有副本?
我知道在trunk上检查了文件的修订版本,当它被删除时,我需要在这两个修订版本之间找到所有分支,标签和可能的其他路径副本。
我终于实现了整个日志的处理在PowerShell中:
$repository = 'http://REPOSITORY/url'
$badPaths = @('/paths/to/first/commit/of/files/to/track')
function Delete-Nodes
{
param([xml]$xml, [string]$xpath)
$nodes = $xml.SelectNodes($xpath);
for ($i = $nodes.Count -1; $i -ge 0; $i--)
{
$nodes[$i].ParentNode.RemoveChild($nodes[$i]) *>$null
}
}
[Console]::OutputEncoding = New-Object -typename System.Text.UTF8Encoding
Measure-Command { [xml]$all_revs = svn log $repository -r1:HEAD -v --xml }
$all_revs.SelectNodes('//logentry').Count
$badPathXpath=[string]::Join(' or ', ($badPaths | % { "text()='$_'" }))
Delete-Nodes -xml $all_revs -xpath "//path[@action='M']"
Delete-Nodes -xml $all_revs -xpath "//path[@action='A' and not($badPathXpath) and not(@copyfrom-path)]" # For additions we only care about our bad paths or any copies (from those)
Delete-Nodes -xml $all_revs -xpath "/log/logentry/paths[not(descendant::path)]"
Delete-Nodes -xml $all_revs -xpath "/log/logentry[not(descendant::paths)]"
$monitoredPaths = @{}
foreach ($logentry in $all_revs.log.logentry)
{
foreach ($path in $logentry.paths.path)
{
$used = $true
$action = $path.action
$from_path = $path.Attributes['copyfrom-path'].Value
$from_rev = $path.Attributes['copyfrom-rev'].Value
$revision = $logentry.revision
$value = $path.InnerText
if ($action -eq 'A' -and -not $from_path)
{
if (($badPaths | % { $value.StartsWith($_) } | Where { $_ }).Count -gt 0)
{
$monitoredPaths[$value] = New-Object PSObject -Property (@{ 'Added' = $revision; 'Deleted' = $null })
}
else
{
$used = $false
}
}
elseif ($monitoredPaths.Count -gt 0 -and $from_path -and -not $monitoredPaths.ContainsKey($value))
{
$paths = $monitoredPaths.Keys | Where-Object { $val = $monitoredPaths[$_]; ($from_path -eq $_ -or $_.StartsWith("$from_path/") -or $from_path.StartsWith("$_/")) -and ($from_rev -ge $val.Added -and (-not $val.Deleted -or $val.Deleted -gt $from_rev)) }
if ($paths.Count -gt 0)
{
foreach ($copied_path in $paths)
{
if ($copied_path.StartsWith("$from_path/"))
{
$sub_directory = $copied_path.SubString($from_path.Length)
$newPath = "$value$sub_directory"
}
else
{
$newPath = "$value"
}
if (($monitoredPaths.Keys | Where-Object { $newPath.StartsWith("$_/") -and -not $monitoredPaths[$_].Deleted }).Count -eq 0)
{
$monitoredPaths[$newPath] = New-Object PSObject -Property (@{ 'Added' = $revision; 'Deleted' = $null })
}
else
{
$used = $false
}
}
}
else
{
$used = $false
}
}
elseif ($action -eq 'D' -and $monitoredPaths.ContainsKey($value))
{
$monitoredPaths[$value].Deleted = $revision
}
elseif ($action -eq 'D')
{
$used = $false
foreach ($path in ($monitoredPaths.Keys | Where-Object { $_.StartsWith("$value/") -and -not $monitoredPaths[$_].Deleted }))
{
$monitoredPaths[$path].Deleted = $revision
$used = $true
}
}
else
{
$used = $false
}
if (-not $used)
{
$logentry.paths.RemoveChild($path) *>$null
}
}
}
简单的办法:去你的build文件夹>>右键点击>>进入了TortoiseSVN >>点击库浏览器。在这里你将得到所有文件存在的路径。 – UDID
你尝试过svn责备吗?它在你的情况下工作吗?你也可以使用'svn log --search'。 – bahrep
@bahrep'svn blame'只显示关于什么版本改变了我文件的哪一部分的信息。我需要找到包含(或曾经包含)一些特定文件的所有分支和标签。 'svn log --search'可能已经可以使用,但我不确定我是否能够搜索文件的重命名,或者只是原始文件名,并希望所有副本都使用该名称。 –