SVN:如何创建分支到主干的差异,以进行代码审查?

发布于 2024-12-27 10:37:24 字数 888 浏览 1 评论 0原文

我有一个合并问题:

我通过复制主干创建了一个分支,创建了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仅此而已 2025-01-03 10:37:24

如果您使用 svn cp 从主干复制了分支,则应该使用 svn merge --reintegrate 重新集成它。您正在合并,没有 --reintegrate 并具有特定修订范围 -r ... (为什么?)。

因此,通常工作流程应该是这样的:

svn cp ^/trunk/ ^/branch/foo

#In the foo branch working copy:
foo $ work, work, work...

#In the working copy of trunk:
trunk $ svn merge --reintegrate ^/branch/foo

然后运行 ​​svn diff 将显示您在分支中所做的所有更改:

trunk $ svn diff
... all the changes that were done in foo ...

还有另一种方法可以解决您的问题。要获取在特定分支中完成的所有(或部分)更改的差异,您不需要合并。使用 svn diff 就足够了:

确定您想要在 diff 中看到哪些更改。
使用 svn log 检查工作完成的 FROM 和 TO 版本:

svn log -v |less

如果您想确定在哪个版本中创建了分支,请执行以下操作:

svn log -v --stop-on-copy | less

最后一个日志条目将是该分支的第一个版本。

现在使用 -r (范围)执行 svn diff

svn diff -r FROM-1:TO .

您可以使用 HEAD 关键字而不是修订号来指示分支中最后提交的修订。

因此,要获取所有分支工作的差异,您需要运行:

svn diff -r FIRST_BRANCH_REV:HEAD

其中 FIRST_BRANCH_REV 是分支的第一个修订版。

If you have copied branch from the trunk with svn cp, you should reintegrate it back with svn merge --reintegrate. You are merging without --reintegrate and with specific revisions range -r ... (why?).

So, generally the workflow should go like this:

svn cp ^/trunk/ ^/branch/foo

#In the foo branch working copy:
foo $ work, work, work...

#In the working copy of trunk:
trunk $ svn merge --reintegrate ^/branch/foo

Then running svn diff will show you all the changes you did in the branch:

trunk $ svn diff
... all the changes that were done in foo ...

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:

svn log -v |less

If you want to determine in which revision you created a branch, do:

svn log -v --stop-on-copy | less

The last log entry will be the first revision of the branch.

Now execute svn diff with -r (range):

svn diff -r FROM-1:TO .

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:

svn diff -r FIRST_BRANCH_REV:HEAD

where FIRST_BRANCH_REV is the first revision of the branch.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文