如何才能檢出在一系列SVN修訂版中修改過的文件?

[英]How can only the files that were modified in a range of SVN revisions be checked out?


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?

是否可以只檢出SVN存儲庫中那些在修訂版或修訂版范圍內修改過的文件,而無需檢出任何未修改的文件?

8 个解决方案

#1


2  

My suggestion is in the same lines as flolo suggests. But, takes a range. You could the following shell function.

我的建議與flolo建議的相同。但是,需要一個范圍。你可以使用以下shell函數。

function checkout_files_in_revrange()
{
  svn_url=$1;
  start_rev=$2;
  end_rev=$3;
  for theCheckoutCanditate in `svn log -r $start_rev:$end_rev --verbose --incremental | grep "   M " | cut -f5 -d' ' | cut -f3- -d/`
  do
     svn co $svn_url/$theCheckoutCandidate -q;
  done
}

#2


2  

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

我的想法是:使用列表的詳細輸出(顯示最后更改的版本),通過awk過濾它,然后檢查其余部分。例如。要搜索版本42中更改的文件,我會使用它

VERSION=42
svn list -v -R -r $VERSION svn://... |  awk "/^[ ]*$VERSION/ {print \$7}" > files_to_checkout

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).

然后做一個svn update -r $ VERSION'cat files_to_checkout'(或者url上的co,取決於你將運行命令的位置)。

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 diff命令,並使用svn co替換-x和--diff-cmd diff命令。這需要一些參數轉移黑客攻擊(這里我不會詳細說明),但只需要一行而不需要中間文件(你也可以在上面保存,但這樣會有成本可讀性)

#3


1  

If you use svn log with the -v (verbose option):

如果使用svn log和-v(詳細選項):

svn log -r <revision> -v <path>

You will get an output that includes the changed files:

您將獲得包含已更改文件的輸出:

 r3 | ciaran | 2008-11-16 12:24:30 +0000 (Sun, 16 Nov 2008) | 1 line
Changed paths:
   A /trunk/apache/apache.conf
   A /trunk/application/controllers

Commit message goes here

You should be able to manipulate that with some grepping etc. to produce a sequence of svn co commands.

您應該能夠通過一些grepping等操作它來生成一系列svn co命令。

#4


1  

We do this in an MSBuild script:

我們在MSBuild腳本中執行此操作:

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

步驟1: - 使用diff命令獲取已修改文件的列表,將輸出重定向到目標目錄中的臨時文件中步驟2: - 將臨時文件讀入itemGroup

<Exec command="$(svnExecutable) diff -r $(StartRevision):$(EndRevision) $(DOUBLE_QUOTES)$(SvnRepositoryPath)/$(DOUBLE_QUOTES) --no-diff-deleted --summarize &gt; $(TempFilePath)" WorkingDirectory="$(WorkDirectory)" />

#5


0  

I'm not completly sure if this is possible but you can also do something like this:

我不完全確定這是否可行,但你也可以這樣做:

svn checkout --revision <revisionNumber> 

to get a certain revision and

得到一定的修改和

svn log --revision <revisionNumber> 

to list all files chaned in a revision

列出修訂中鏈接的所有文件

#6


0  

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

在大多數人建議的幾乎相同的行中(但只有在具有grep和awk的系統中),您可以通過執行來獲取列表

svn log -v --revision <revision_number> | grep "^ " | awk '{print $2}'.

svn log -v --revision | grep“^”| awk'{print $ 2}'。

#7


0  

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.

假設您有一個現有的工作副本,您應該在包含您正在查看的文件的目錄的根目錄上使用'svn update',因為它可以准確地檢索當前修訂版和HEAD修訂版之間的更改。

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.

較早的源代碼管理系統(如CVS和VSS)要求服務器為每個文件更改此文件?而subversion只是將樹的更改作為單個操作發送。當您將文件列表傳遞給svn update時,您沒有這個優勢。

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.

因此,轉移更改內容的最有效方法就是更新。這僅傳輸HEAD中的更改的二進制差異與工作副本的基本版本相比。


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.

如果您要解決的問題是svn update要慢,那么我們正在嘗試解決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.

該版本將引入一種新的工作副本數據存儲格式,該格式將使得必須更快地鎖定整個工作副本(如更新)的簡單操作。

#8


0  

svn diff -r starting_revision:ending_revision_or_HEAD --summarize

svn diff -r starting_revision:ending_revision_or_HEAD --summarize


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2008/11/26/73009904cb17e887c7152768adf85a3f.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com