如何只检出在一系列 SVN 修订版中修改过的文件?
是否可以仅从 SVN 存储库中签出在一个修订版或修订版范围内修改过的文件,而不签出任何未修改的文件?
Is it possible to checkout only those files from a SVN repository that were modified in a revision or range of revisions, without checking out any files that were not modified?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
我的建议与弗洛洛的建议相同。 但是,需要一个范围。
您可以使用以下 shell 函数。
My suggestion is in the same lines as flolo suggests. But, takes a range.
You could the following shell function.
据我所知,现在有直接的方法来获取更改的文件而不是全部。
我的想法是:使用列表的详细输出(显示最后更改的版本),通过 awk 过滤它,然后检查其余部分。 例如,要搜索版本 42 中更改的文件,我将使用此
命令,然后执行
svn update -r $VERSION 'cat files_to_checkout'
(或 url 上的 co,具体取决于您将在何处运行命令)。编辑:另外更短:
使用 svn diff 命令,并用 -x 和 --diff-cmd 将 diff 命令替换为 svn co。 这需要一些参数转移黑客(我不会在这里详细说明),但只需要一行并且不需要中间文件(您也可以在上面保存,但这会增加可读性)
There is afaik now direct way to get just the changed files and not all.
My idea would be: use the verbose output of the list (which shows the last changed version), filter it through awk, and checkout the rest. E.g. to search the files which changed in version 42 I would use this
And later do a
svn update -r $VERSION 'cat files_to_checkout'
(or a co on the url, depending on where you will run the command).EDIT: Additional even shorter:
use the svn diff command, and replace with -x and --diff-cmd the diff command with svn co. This requires some argument shifting hacking (which I wont elaborate here), but needs just one line and no intermedate file (which you could save above too, but that would have cost readability)
如果您将 svn log 与 -v (详细选项)一起使用:
您将获得包含更改的文件的输出:
您应该能够通过一些 grep 等操作它来生成一系列 svn co 命令。
If you use svn log with the -v (verbose option):
You will get an output that includes the changed files:
You should be able to manipulate that with some grepping etc. to produce a sequence of svn co commands.
我们在 MSBuild 脚本中执行此操作:
步骤 1: - 使用 diff 命令获取修改文件的列表,将输出重定向到目标目录中的临时文件
步骤 2: - 将临时文件读入 itemGroup
We do this in an MSBuild script:
Step 1: - Use the diff command to get the list of modified files, redirect output into a temporary file in the target directory
Step 2: - Read the temporary file into an itemGroup
我不完全确定这是否可能,但您也可以执行以下操作:
获取某个修订版并
列出修订版中更改的所有文件
I'm not completly sure if this is possible but you can also do something like this:
to get a certain revision and
to list all files chaned in a revision
在与大多数人建议的几乎相同的行中(但是仅在具有 grep 和 awk 的系统中),您可以通过执行
svn log -v --revision来获取列表。 | grep“^”| awk '{print $2}'.
In almost the same lines as most of the folks have suggested, (however only in a system with grep and awk), you can get the list by executing
svn log -v --revision <revision_number> | grep "^ " | awk '{print $2}'
.回答你的问题的另一种方法:
假设你有一个现有的工作副本,你应该只在包含你正在查看的文件的目录的根目录上使用“svn update”,因为它可以准确地检索当前版本和 HEAD 版本之间的更改尽可能少的数据。
较旧的源代码管理系统(例如 CVS 和 VSS)会向服务器询问每个文件此文件是否已更改?,而 subversion 只是将树的更改作为单个操作发送。 当您将文件列表传递给 svn update 时,您就没有这个优势。
因此,传输已更改内容的最有效方法就是更新。 与工作副本的基本版本相比,这仅传输 HEAD 中更改的二进制差异。
如果您试图解决的问题是 svn update 速度太慢,那么我们正在尝试为 Subversion 1.7 解决这个问题。
此版本将引入一种新的工作副本数据存储格式,该格式将使必须锁定整个工作副本(例如更新)的简单操作变得更快。
Another take at answering your question:
Assuming you have an existing workingcopy you should just use 'svn update' on the root of the directory containing the files you are looking at as that retrieves exactly what changed between your current revision and the HEAD revision with the least data possible.
Older sourcecode management systems like CVS and VSS asked the server for every file has this file changed?, while subversion just sends the changes of a tree as a single action. When you pass a list of files to svn update you don't have this advantage.
Therefore the most efficient way to transfer what has changed is just updating. This only transfers a binary diff of the changes in HEAD compared to the base version of your working copy.
If the problem you are trying to solve is that svn update is to slow, then we are trying to solve that for Subversion 1.7.
This version will introduce a new working copy data storage format that will make simple operations that have to lock an entire working copy (like updating) much faster.
svn diff -rstarting_revision:ending_revision_or_HEAD --summarize
svn diff -r starting_revision:ending_revision_or_HEAD --summarize