简体   繁体   English

递归列出所有svn:externals?

[英]List all svn:externals recursively?

How can I get a list of all svn:externals (recursively) in a directory? 如何在目录中(递归)获取所有svn:externals的列表? Is there any utility for this? 有任何实用程序吗?

(I'm using Windows (and tortoise)) (我正在使用Windows(和乌龟))

I have a bunch of svn:externals linking to different shared parts of my project and I when I branch it's usually quite error prone to find all externals and changed them so that the link to paths within the new branch. 我有一堆svn:externals链接到项目的不同共享部分,而我分支时,查找所有外部元素并更改它们通常很容易出错,以便链接到新分支中的路径。

Do the following in the root of your working copy: 在工作副本的根目录中执行以下操作:

svn propget svn:externals -R

As discussed in the comments below, this does not list externals in externals. 如下面的评论中所讨论的,这未在外部列出外部。

Note for TortoiseSVN users: there is an option in the TortoiseSVN installer to also install the SVN command line client. 给TortoiseSVN用户的注意事项:TortoiseSVN安装程序中有一个选项还可以安装SVN命令行客户端。 This option is not enabled by default. 默认情况下不启用此选项。

Manually changing all of those external properties sounds tedious. 手动更改所有这些外部属性听起来很乏味。 Have you looked at the new functionality for externals added in Subversion 1.5? 您是否看过Subversion 1.5中新增的外部功能

Subversion 1.5 takes a huge step in relieving these frustrations. Subversion 1.5在缓解这些挫败感方面迈出了巨大的一步。 As mentioned earlier, the URLs used in the new externals definition format can be relative, and Subversion provides syntax magic for specifying multiple flavors of URL relativity. 如前所述,新的外部定义格式中使用的URL可以是相对的,并且Subversion提供了语法魔术,用于指定URL相对性的多种形式。

../ ../

Relative to the URL of the directory on which the svn:externals property is set 相对于设置svn:externals属性的目录的URL

^/ ^ /

Relative to the root of the repository in which the svn:externals property is versioned 相对于版本库中svn:externals属性的根目录

// //

Relative to the scheme of the URL of the directory on which the svn:externals property is set 相对于设置svn:externals属性的目录的URL方案

/ /

Relative to the root URL of the server on which the svn:externals property is versioned 相对于版本svn:externals属性的服务器的根URL

Maybe one of those would help? 也许其中之一会有所帮助? I guess it depends on exactly how you are branching and what your repository structure looks like. 我猜这完全取决于您的分支方式和存储库结构。

My workaround for TortoiseSVN: 我的TortoiseSVN解决方法:

Open the "Branch/tag..." dialog from the SVN context menu. 从SVN上下文菜单中打开“分支/标签...”对话框。 The lower dialog shows all externals including nested externals. 下部对话框显示了所有外部组件,包括嵌套的外部组件。

Maybe, as a workaround, you could structure your project in such a way that all externals are set on the same folder, for example on the project folder just below Trunk. 也许,作为一种解决方法,您可以采用以下方式来构造项目:将所有外部组件都设置在同一文件夹中,例如在Trunk下面的项目文件夹中。 (This doesn't mean that all external folders have to be at the same depth by the way.) Then you can right-click on your project folder, then Properties..., then the tab Subversion, then Properties... then double-click svn:externals. (这并不意味着所有外部文件夹的深度都必须相同。)然后,您可以右键单击项目文件夹,然后依次单击“属性...”,“ Subversion”选项卡,“属性...”双击svn:externals。

I used the answer of Wim Coenen and wrote the following script to create a list of all revisions: 我使用了Wim Coenen的答案,并编写了以下脚本来创建所有修订的列表:

getSvnRevs() {
  cd "$1"
  wcver="$(svnversion)"
  [ -n "$wcver" ] || panic "Unable to get version for $wcdir"
  echo "$1: $wcver"
  svn propget svn:externals -R | while read a b c d e; do
    [ -n "$a" ] || continue
    if [ "$b" = "-" ]; then
      wcparent="$a"
      wcdir="$wcparent/$c"
      [ -z "$e" ] || panic "Invalid format #1"
    else
      [ -n "$wcparent" ] || panic "Invalid format #2"
      wcdir="$wcparent/$a"
      [ -z "$c" ] || panic "Invalid format #3"
    fi
    [ -d "$wcdir" ] || panic "Invalid directory: $wcdir"
    wcver="$(svnversion "$wcdir")"
    [ -n "$wcver" ] || panic "Unable to get version for $wcdir"
    echo "$1/$wcdir: $wcver"
  done
}

Fortunately, I don't have nested externals, so I didn't have to test this and I guess it wouldn't work. 幸运的是,我没有嵌套的外部组件,因此我不必对此进行测试,我猜想它是行不通的。 But if you need this, it's probably enough to just call this function recursively. 但是,如果需要此功能,只需递归调用此函数就足够了。 Also, I never tested with filenames which need escaping. 另外,我从未测试过需要转义的文件名。 It likely won't work then. 那时可能不起作用。

DISCLAIMER: I know the original question was about windows, and shell script won't work there unless you're using cygwin or similar. 免责声明:我知道最初的问题是关于Windows的,除非您使用cygwin或类似工具,否则shell脚本将无法在其中运行。

I took Daniel Alder's answer , removed the svnversion calls, and made it recursive (NOTE: read abcde doesn't work if there's a space in either the source or destination). 我接受了Daniel Alder的回答 ,删除了svnversion调用,并使其进行了递归(注意:如果源或目标中有空格,则read abcde无效)。 This is a bash script, so you'll either need something like Cygwin or use the Windows Subsystem for Linux . 这是一个bash脚本,因此您将需要Cygwin之类的东西,或者使用Windows Linux子系统

getSvnExternals() {
  svnbase="$1"
  svnpath="$2"
  svn propget svn:externals -R "$svnbase/$svnpath" 2> /dev/null | while read a b c d e; do
    [ -n "$a" ] || continue
    if [ "$b" = "-" ]; then
      wcparent="$a"
      external="$c"
      wcdir=$(echo "$wcparent/$d" | sed s#^./##)
      [ -z "$e" ] || echo "WARNING: Invalid format #1. line='$a $b $c $d $e'"
    else
      [ -n "$wcparent" ] || echo "WARNING: Invalid format #2. wcparent=$wcparent"
      external="$a"
      wcdir=$(echo "$wcparent/$b" | sed s#^./##)
      [ -z "$c" ] || echo "WARNING: Invalid format #3. line='$a $b $c $d $e'"
    fi
    echo "$1/$wcdir: $external"
    ## recurse into external directory
    [ -d "$wcdir" ] && getSvnExternals "$1/$wcdir"
  done
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM