【问题标题】:How to list switched svn directories recursively in a working copy?如何在工作副本中递归列出切换的 svn 目录?
【发布时间】:2012-10-06 18:48:24
【问题描述】:

我已从存储库中签出工作副本并将一些目录切换到不同的 URL,但在同一个存储库(相同的主机和 svn 服务器)上。

如何列出这些切换的目录?

我们为内部目的使用了许多切换,这将有助于在工作副本中轻松列出所有这些,直到消除这种快速而肮脏的切换使用。

【问题讨论】:

    标签: svn recursion svn-switch


    【解决方案1】:

    (1) @ks1322 提供的答案很简洁,除了一个小调整外,它工作正常:应该使用“^URL”而不是“URL”,因为某些文件也会报告Copied from URL 行。这是我系统上的一些示例输出,显示了这个小问题:

    URL: file:///C:/usr/tmp/SvnSandbox/branches/sub-branch1
    URL: file:///C:/usr/tmp/SvnSandbox/branches/sub-branch1/commands
    URL: file:///C:/usr/tmp/SvnSandbox/branches/sub-branch1/commands/show%20test.cmd
    URL: file:///C:/usr/tmp/SvnSandbox/trunk/commands/subdir
    URL: file:///C:/usr/tmp/SvnSandbox/trunk/commands/subdir/stuff.txt
    URL: file:///C:/usr/tmp/SvnSandbox/branches/sub-branch1/commands/reversion_test.txt
    URL: file:///C:/usr/tmp/SvnSandbox/branches/sub-branch1/file-on-branch1.txt
    Copied From URL: file:///C:/usr/tmp/SvnSandbox/branches/branch1/file-on-branch1.txt
    URL: file:///C:/usr/tmp/SvnSandbox/branches/sub-branch1/externals
    URL: file:///C:/usr/tmp/SvnSandbox/branches/sub-branch1/file-on-branch-and-subbranch.txt
    URL: file:///C:/usr/tmp/SvnSandbox/branches/sub-branch1/file-on-sub-branch1.txt
    

    (2) 对于 Windows 系统,一个等效命令(使用 PowerShell)是:

    svn info --depth=infinity | Select-String ^URL
    

    (3) 但是对于具有更高信噪比的输出,请尝试以下操作:

    Get-SvnInfo . -Recurse -ContainersOnly Path, URL | 
    Format-Table Path, `
        @{ n='Branch'; `
           e={$_.URL -replace ".*(trunk|branches/[^/]*).*", '$1'} }
    

    该序列的输出一目了然地显示了您需要了解的内容。从我的第一个示例中使用的同一示例树中,它揭示了以下内容:

    Path                              Branch
    ----                              ------
    commands                          branches/sub-branch1
    externals                         branches/sub-branch1
    commands\subdir                   trunk
    externals\commonlib               trunk
    externals\commonlib\textfiles     trunk
    

    Get-SvnInfo cmdlet 可从我的开源 PowerShell 库中获得——有关详细信息,请参阅我的API bookshelf 上的 PowerShell 书籍。)

    【讨论】:

      【解决方案2】:

      您可以使用以下命令递归列出工作副本中所有文件和目录的 URL:

      svn info --depth=infinity|grep URL
      

      您会在输出中看到切换的 URL,因此也会看到切换的目录。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-06-16
        • 2011-08-08
        • 2012-02-03
        • 1970-01-01
        • 1970-01-01
        • 2013-01-11
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多