SVN:如何创建分支到主干的差异,以进行代码审查?
我有一个合并问题:
我通过复制主干创建了一个分支,创建了 rev 1000。然后我添加了一个 新文件 blah.txt
到分支。现在我想合并这个(和 其他)更改回我的主干结帐:
cd ~/trunk-checkout
svn merge -r 1000:2000 $REPOS/branches/foo
A blah.txt
这会在主干结帐中创建我的新文件 blah.txt
。但当我 说:
svn diff blah.txt
输出为空。输出不应该是整个文件吗,因为它 后备箱中尚不存在?
我如何将 svn-diff 获取到主干,其中将包含 全新文件 blah.txt
?
即使我这样说(在新文件 blah.txt
所在的目录中):
svn diff -r HEAD $REPOS/trunk/foo
它也是空的。
我的问题的背景是:我需要将代码(位于分支上)的差异提交到主干以进行代码审查(请参阅 此处)。差异应该如下所示:
$ svn diff blah.txt
Index: blah.txt
===================================================================
--- blah.txt (revision 0)
+++ blah.txt (revision 0)
@@ -0,0 +1 @@
+hello world
I have a merging problem:
I created a branch by copying the trunk, creating rev 1000. Then I added a
new file blah.txt
to the branch. Now I want to merge this (and
other) changes back to my checkout of the trunk:
cd ~/trunk-checkout
svn merge -r 1000:2000 $REPOS/branches/foo
A blah.txt
That creates my new file blah.txt
in the trunk checkout. But when I
say:
svn diff blah.txt
the output is empty. Shouldn't the output be the whole file, since it
doesn't yet exist in the trunk?
How can I get the svn-diff
to the trunk, which would contain the
whole new file blah.txt
?
Even when I say this (in the directory where the new file blah.txt
is):
svn diff -r HEAD $REPOS/trunk/foo
it is empty.
The background of my question is: I need to submit a diff of my code (which is on the branch) to the trunk for code review (see here). The diff should look like this:
$ svn diff blah.txt
Index: blah.txt
===================================================================
--- blah.txt (revision 0)
+++ blah.txt (revision 0)
@@ -0,0 +1 @@
+hello world
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 svn cp 从主干复制了分支,则应该使用 svn merge --reintegrate 重新集成它。您正在合并,没有
--reintegrate
并具有特定修订范围-r ...
(为什么?)。因此,通常工作流程应该是这样的:
然后运行 svn diff 将显示您在分支中所做的所有更改:
还有另一种方法可以解决您的问题。要获取在特定分支中完成的所有(或部分)更改的差异,您不需要合并。使用 svn diff 就足够了:
确定您想要在 diff 中看到哪些更改。
使用 svn log 检查工作完成的 FROM 和 TO 版本:
如果您想确定在哪个版本中创建了分支,请执行以下操作:
最后一个日志条目将是该分支的第一个版本。
现在使用
-r
(范围)执行svn diff
:您可以使用
HEAD
关键字而不是修订号来指示分支中最后提交的修订。因此,要获取所有分支工作的差异,您需要运行:
其中 FIRST_BRANCH_REV 是分支的第一个修订版。
If you have copied branch from the trunk with
svn cp
, you should reintegrate it back withsvn merge --reintegrate
. You are merging without--reintegrate
and with specific revisions range-r ...
(why?).So, generally the workflow should go like this:
Then running
svn diff
will show you all the changes you did in the branch:There is another way to solve your problem. To get diff of all (or part of) the changes that were done in the specific branch you don't need to merge. Using
svn diff
is enough:Determine which changes you want to see in the diff.
Use
svn log
to check FROM which and TO which revision the work was done:If you want to determine in which revision you created a branch, do:
The last log entry will be the first revision of the branch.
Now execute
svn diff
with-r
(range):You can use
HEAD
keyword instead of revision number to indicate the last committed revision in the branch.So to get a diff of all your branch work you will need to run:
where
FIRST_BRANCH_REV
is the first revision of the branch.