SVN仅从存储库更新特定文件 [英] SVN Update specific files from repository only

查看:169
本文介绍了SVN仅从存储库更新特定文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个存储库有很多千兆字节,我不需要其中的99%.我想做的只是获取/更新* .js * .css * .html .doc 和* .pdf文件.其余的是巨大的,我想留在那里,而不是浪费时间和磁盘空间,因为我不需要查看它们,并且我永远都不会更改它们.

There's this repository which is many many gigabytes, 99% of which I don't need. What I want to do is get/update only the *.js *.css *.html .doc and *.pdf files. The rest, which are the enormous ones, I want to leave up there and not waste time and disk space getting because I don't need to look at them and I'll never be changing them.

我意识到svn:ignore功能不是我所需要的,它仅与检入和忽略的内容有关.我也知道SVN中没有任何参数或设置可以用来做我想做的事情.

I realize that the svn:ignore feature isn't what I need, that's related only to what gets checked in and what gets ignored. I also know that there's no parameters or settings in SVN that I can take advantage of to do what I want.

我发现,如果我右键单击SVN文件夹并选择检查修改",然后在下一个对话框中选择检查存储库",那么我会得到我没有的文件的完整列表有.然后,将扩展名"添加到列标题并按扩展名排序是一项容易的任务.然后,我可以向下滚动并找到分组在一起的所有.js文件.

What I have found though is that if I right-click on my SVN folder and select "Check for Modifications" and then in the next dialog choose "Check repository" then I get a full list of the files I don't have. It's then an easy task to add "Extension" to the column headers and sort by extension. I can then scroll down and find all the .js files grouped together.

这是我#fail发生的地方.如果我右键单击JS文件的 ONE 并选择UPDATE,那么它将关闭该文件并创建支持该文件所必需的子目录层次结构.这正是我想要发生的事情.在这一点上,我想知道已经找到了我所需要的东西.这不是一个麻烦的过程,我可以接受.然后,我选择了所有JS文件并单击鼠标右键.我注意到的第一件事是出现的上下文菜单中的选项较少,令人不安.但是这里有UPDATE选项,所以我不太担心.我选择UPDATE,然后单击OK,就像我为先前尝试过的单个JS文件所做的一样.接下来发生的事情虽然很奇怪.它不会对单个文件重复执行此过程,而是对所有选定文件重复此过程,而是针对每个文件显示已跳过"并报告已完成.每次都会发生这种情况.我可以手动处理每个文件(这将需要几个小时),但无法一次完成所有操作.

Here's where my #fail happens. If I right-click on ONE of the JS files and select UPDATE, then it will bring the file down and create the sub-directory hierarchy necessary to support that file. This is exactly what I'd want to happen. At this point I jump in the air thinking I've found what I need. This isn't such a troublesome process, I can live with this. Then I selected all of the JS files and right-clicked. First thing I noticed is that the context menu that appears has less options, that's troubling. But the UPDATE option is there, so I'm not too worried. I choose UPDATE then click OK, just like I did for the one single JS file I'd earlier tried. What happens next is the weird thing though. Instead of repeating the process that happened with the one single file, but this time to all selected files, it shows "Skipped" against each file and reports it's done. This happens every time. I can do each file manually (which would take hours) but I can't do them all at once.

帮助.我正在虚拟机中执行此操作,我不想将其大小增加四倍,而只获取不需要的文件.

Help. I'm doing this in a virtual machine which I'd rather not quadruple the size of just to get files I don't need.

推荐答案

很抱歉延迟回答,这里发生了很多事情,我也不得不花一些时间来使它工作.正如您已经指出的那样,没有直接的方法可以进行仅扩展签出".但是有一种方法可以使用 Subversion命令行工具和我编写的批处理脚本.通过使用Subversion的稀疏目录功能,可以让您指定结帐应具有的深度".通过指定深度empty,将创建​​一个空的工作副本,并且实际上未检出任何文件或文件夹.然后,您可以将选择的即时文件和文件夹从存储库update放入该工作副本中.这样可以创建您要执行的仅扩展签出"操作.

Sorry for the delayed answer, there's been a lot going on and I also had to spend some time to get this working. As you already noted, there is no straightforward way to do an "extension-only-checkout". But there is a way using Subversion command-line tools and a batch script I wrote. It works by using the sparse directories feature of Subversion, which lets you specify which "depth" a checkout should have. By specifying a depth of empty, an empty working copy is created and no files or folders are actually checked out. Then, you can update immediate files and folders of your choice from the repository into that working copy. This allows to create that "extension-only-checkout" which you're after.

我编写的脚本允许您在EXTENSIONS变量中指定多个扩展名,以空格分隔.然后在SVN_ROOT变量中指定的存储库中扫描具有给定扩展名的文件.然后继续构建工作副本,该工作副本仅包含支持具有指定扩展名的文件(使用上述方法)所需的目录结构.我已经对其进行了相当多的测试,希望它能满足您的需求.

The script I wrote allows you to specify multiple extensions in the EXTENSIONS variable separated by spaces. The repository specified in the SVN_ROOT variable is then scanned for files with the given extensions. Then it proceeds to build up a working copy which consists only of the directory structure needed to support the files having the extensions you specified (using the method described above). I tested it quite a bit and hope it will suit your needs.

注意:根据存储库的大小和与指定扩展名匹配的文件数,创建工作副本的过程将花费一些时间.

Note: Depending on the size of the repository and the number of files matching the specified extensions, the process of creating the working copy will take some time.

@ECHO OFF
SetLocal EnableDelayedExpansion

SET SVN_ROOT=svn://your-repository.com/svn/your-project
SET EXTENSIONS=.js .css .html .doc .pdf
SET ROOT_DIR=%CD%

ECHO Listing repository...
svn -R ls %SVN_ROOT% > _files-all.txt

REM filter list for specified extensions
FOR %%H IN (%EXTENSIONS%) DO (
    TYPE _files-all.txt | FINDSTR /I /R "%%H$" >> _files-selected.txt
)

REM initial checkout in empty mode
svn co %SVN_ROOT% --depth empty .

FOR /F "tokens=*" %%I IN (_files-selected.txt) DO (
    REM "escape" path elements by wrapping them into double quotes
    SET TMP_PATH=%%I
    SET TMP_PATH="!TMP_PATH:/=" "!"
    ECHO Fetching %%I
    REM iterate over path elements
    FOR %%J IN (!TMP_PATH!) DO (
        REM "unescape" each path element again
        SET PATH_ELEM=%%J
        SET PATH_ELEM=!PATH_ELEM:~1,-1!
        REM if we don't have this element, fetch it from repository
        IF NOT EXIST "!PATH_ELEM!" (
            svn up %%J --depth empty 2>&1 > nul
        )
        REM if the element is a directory, enter it
        IF EXIST %%~sJ\NUL CD %%J
    )
    CD !ROOT_DIR!
)

REM clean up temporary files
DEL _files-all.txt _files-selected.txt

这篇关于SVN仅从存储库更新特定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆