SVN 签出按文件扩展名过滤?
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
正如我所说的这里,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.
您不能仅查看几个特定文件 - 您只能查看整个文件夹。 您可以重新安排您所签出的内容的组织,或者您可以从其他地方复制工作副本并进行更新。
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.
我刚刚尝试了迈克尔·哈克纳提出的方法。 下面是DOS系统的实现。 请注意,在运行此脚本之前,您必须签出空文件夹。
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.
对于 Michael Hackner 答案的 powershell 特定实现,请尝试以下操作:
我在这里的特定用例是找到一个一堆类似名称的文件(在本例中为 *special.xml),并将它们全部转储到一个文件夹中,并且具有本质上唯一的名称。 我使用了一个中间文件来存储整个存储库列表,但如果这对您更好的话,也可以将其全部内联。
For a powershell specific implementation of the answer from Michael Hackner, try something like:
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.
最简单、最正确的方法是:不要这样做!
如果第三方文件夹中有一些垃圾,其中应该有需要检出的 .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.
这是可能的:您可以
svn checkout
一个空目录,然后为您想要的每个文件svn update filename
。您的脚本可以执行以下操作:
svn checkout svn://path/to/repos/directory --深度空
svn list --recursive svn://path/to/repos/directory
grep
svn update --parents
每个文件这将给出您想要的没有某些文件或文件扩展名的工作副本的结果。
当然,还有你提到的“人们[检查]大量的绒毛”的问题,但这是一个单独的问题。
This is possible: you can
svn checkout
an empty directory, and thensvn update filename
for each file that you do want.Your script can do something like:
svn checkout svn://path/to/repos/directory --depth empty
svn list --recursive svn://path/to/repos/directory
grep
svn update --parents
each fileThat 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.