SVN 签出按文件扩展名过滤?

发布于 2024-07-08 04:38:10 字数 389 浏览 7 评论 0原文

我有一个 DOS 批处理文件形式的自制自动构建脚本。 在该脚本的一部分中,我检查(使用“svn checkout”)我们的 SVN 存储库的一部分,其中包括我们项目中使用的一堆第三方内容。 这个批处理文件在很长一段时间内表现得很好,但现在人们已经将大量的废话(文档、示例代码等)签入第三方区域,并且该脚本的签出部分变得慢了很多。 我想通过只检查我们需要的东西来缓解这个问题——在我们的例子中主要是 dll 文件。 所以,我的问题是:查看按文件扩展名过滤的 SVN 存储库的最佳方法是什么?

我在 svn 帮助中没有看到任何明显的方法来做到这一点。 我有一个以某种方式包装 svn.exe 的 .NET 实用程序库,我正在考虑扩展它以仅检索与我感兴趣的扩展相匹配的内容。 但我更愿意使用一种更简单或现有的方法(如果存在)。

I have a home-grown automated build script in the form of a DOS batch file. In part of that script, I check out (with "svn checkout") a section of our SVN repository that includes a bunch of third-party stuff that's used in our projects. This batch file performed pretty well for a long time, but now people have checked in lots of fluff (docs, sample code, etc.) into the third-party area and the checkout part of this script has gotten lots slower. I'd like to mitigate this by checking out only the stuff we need -- mostly dll files in our case. So, my question is this: what's the best way to check out an SVN repository filtered by file extension?

I didn't see any obvious way to do this in the svn help. I have a .NET utility library that wraps svn.exe in some ways, and I was thinking of extending this to retrieve only content that matched my extensions of interest. But I'd prefer to use an easier or existing method if one exists.

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

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

发布评论

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

评论(6

很酷又爱笑 2024-07-15 04:38:11

正如我所说的这里,SVN 本身只有一个内置选项:SVN 中的一项新功能1.5 称为稀疏签出,但是您只能在目录级别选择签出,因此您必须将不需要的文件排序到不同的目录中。

As I told here, there is only one option build into SVN itself: A new feature in SVN 1.5 called sparse checkout, however you can only select checkout on directory level, so you have to sort the files you do not need in a different directory.

挽手叙旧 2024-07-15 04:38:11

您不能仅查看几个特定文件 - 您只能查看整个文件夹。 您可以重新安排您所签出的内容的组织,或者您可以从其他地方复制工作副本并进行更新。

You can't check out just a few specific files -- you can only check out a whole folder. You can rearrange the organization of what you're checking out, or you can just copy a working copy from somewhere else and update.

半边脸i 2024-07-15 04:38:11

我刚刚尝试了迈克尔·哈克纳提出的方法。 下面是DOS系统的实现。 请注意,在运行此脚本之前,您必须签出空文件夹。

@echo off

svn list --recursive https://path_to_repository_folder | find /I ".sql" > filelist.txt

REM Specify a custom delim. Otherwise space in filename will be treated as a delimiter.
FOR /F "delims=|" %%i  IN (filelist.txt) DO (
    echo -------------
    echo %%i
    svn update --parents "%%i"
)

I just tried the approach presented by Michael Hackner. Below is the implementation for a DOS system. Note that you have to to checkout the empty folder before running this script.

@echo off

svn list --recursive https://path_to_repository_folder | find /I ".sql" > filelist.txt

REM Specify a custom delim. Otherwise space in filename will be treated as a delimiter.
FOR /F "delims=|" %%i  IN (filelist.txt) DO (
    echo -------------
    echo %%i
    svn update --parents "%%i"
)
还在原地等你 2024-07-15 04:38:11

对于 Michael Hackner 答案的 powershell 特定实现,请尝试以下操作:

svn ls http://svn-server/src --recursive | Out-File svn.txt
Get-Content .\svn.txt | where {$_.toLower().EndsWith('special.xml')} | select -First 200 | foreach {New-Object PSObject -Property @{ Path = $_; Munged = $_.Replace('/', '_') } } | foreach { svn export "http://svn-server/src/$($_.Path)" $($_.Munged) }

我在这里的特定用例是找到一个一堆类似名称的文件(在本例中为 *special.xml),并将它们全部转储到一个文件夹中,并且具有本质上唯一的名称。 我使用了一个中间文件来存储整个存储库列表,但如果这对您更好的话,也可以将其全部内联。

For a powershell specific implementation of the answer from Michael Hackner, try something like:

svn ls http://svn-server/src --recursive | Out-File svn.txt
Get-Content .\svn.txt | where {$_.toLower().EndsWith('special.xml')} | select -First 200 | foreach {New-Object PSObject -Property @{ Path = $_; Munged = $_.Replace('/', '_') } } | foreach { svn export "http://svn-server/src/$($_.Path)" $($_.Munged) }

My particular use case here is finding a bunch of similarly named files (in this case *special.xml) and dumping them all into a single folder, with essentially unique names. I have used an intermediate file to store the entire repo listing, but this could all be inlined as well if that's better for you.

嘿咻 2024-07-15 04:38:11

最简单、最正确的方法是:不要这样做!

如果第三方文件夹中有一些垃圾,其中应该有需要检出的 .dll 文件 - 将该垃圾删除到其他位置! 无论如何,它不属于这里。

The most simple and a correct way to do this: DON'T DO IT!

If there is some crap in third party folder where there suppose to be .dll files that needs to be checkout - remove that crap to a different location! It does not belong here anyway.

心舞飞扬 2024-07-15 04:38:10

这是可能的:您可以svn checkout一个空目录,然后为您想要的每个文件svn update filename

您的脚本可以执行以下操作:

  1. svn checkout svn://path/to/repos/directory --深度空
  2. svn list --recursive svn://path/to/repos/directory
  3. 通过过滤器传递结果,删除禁止的文件扩展名,例如 grep
  4. 迭代这个新的过滤列表并 svn update --parents 每个文件

这将给出您想要的没有某些文件或文件扩展名的工作副本的结果。

当然,还有你提到的“人们[检查]大量的绒毛”的问题,但这是一个单独的问题。

This is possible: you can svn checkout an empty directory, and then svn update filename for each file that you do want.

Your script can do something like:

  1. svn checkout svn://path/to/repos/directory --depth empty
  2. svn list --recursive svn://path/to/repos/directory
  3. Pipe that result through a filter that removes the forbidden file extensions, e.g. grep
  4. Iterate over this new filtered list and svn update --parents each file

That would give your desired result of a working copy without certain files or file extensions.

Of course, there is also the issue that you mention of “people [checking] in lots of fluff” but that’s a separate matter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文