与先前的修订版本合并(“回滚"版本) [英] Merging from previous revision (a "rollbacked" one)

查看:121
本文介绍了与先前的修订版本合并(“回滚"版本)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在项目的 SVN干线中工作,并且我是唯一的开发人员.几天前,我被要求实施一项新要求,我开始在后备箱本身中执行此操作(糟糕的选择,BTW):

I'm working in the SVN trunk of my project and I'm the only developer. Some days ago, I was asked to implement a new requirement, I began doing it in the trunk itself (bad choice, BTW):

r1154: Last revision with the old version (2.1.12).
r1155: I commited the new version here (3.0.0).

后来,我被要求修复2.x版本中的一些错误,因此我做了反向合并,并获得与以前相同状态的下一个修订版本:

Later on, I was asked to fix some bugs in 2.x version, so I did a reverse merge and got the next revision in the same state as before:

r1156: Reverse merge to recover r1154 state as HEAD.
r1157: Some modifications.

现在我的问题是我想恢复在r1155中所做的修改.基本上,我想将它们与当前主干状态合并.如何实现:

Now my problem is I want to recover the modifications I did in r1155. Basically, I want to merge them with my current trunk state. How is it possible to achieve:

r1158: r1157 code merged with r1155 new features.

推荐答案

如果您在r1157中所做的错误修复与您最初在r1155中添加的新功能无关,则可以尝试合并变更集像这样将新功能放回后备箱:

If the bug fixes you made in r1157 are independent of the new feature you originally added in r1155, you can try merging the changeset for the new feature back into trunk like this:

svn merge -c 1155 TRUNK_URL WORKING_COPY_PATH

这将获取r1154r1155之间的差异,并尝试将它们应用在r1157之上(假设您的工作副本是最新的).

This takes the differences between r1154 and r1155 and tries to apply them on top of r1157 (assuming your working copy is up to date).

或者,您可以尝试通过反向合并删除了新功能的变更集来撤消撤消":

Alternatively, you can try to "undo the undo" by reverse merging the changeset that removed the new feature:

svn merge -c -1156 TRUNK_URL WORKING_COPY_PATH

这采用了r1156r1155之间的差异,并尝试将它们应用在r1157之上(假设您的工作副本是最新的). -1156中的减号至关重要,因为它表明这是反向合并.

This takes the differences between r1156 and r1155 and tries to apply them on top of r1157 (assuming your working copy is up to date). The minus sign in -1156 is critical because it indicates that this is a reverse merge.

请注意,这实际上并未删除r1156.您也没有将存储库还原"到较早的版本. r1156已经提交,因此它将永久保留在存储库中,并且HEAD将永远不会再指向r1156.您只是将与该修订版相同的更改应用于工作副本,但顺序相反.这是在SVN中进行合并时需要了解的关键点.

Note that this does not actually remove r1156. Nor are you "restoring" the repository to an earlier revision. r1156 was already committed, so it will stay in the repository forever, and HEAD will never point to r1156 again. You are simply applying the same changes as were made in that revision, but in reverse order, to your working copy. This is a critical point that you need to understand when doing merges in SVN.

无论哪种方式,如果您在错误修复和新功能中触摸相同的代码位,则可能会遇到合并冲突,必须手动解决.解决所有冲突后,现在必须将更改提交到工作副本:

Either way, if you touched the same bits of code in your bug fixes and in the new feature, you may get merge conflicts, which you will have to resolve manually. When you have resolved all conflicts, you now have to commit your changes to your working copy:

svn commit WORKING_COPY_PATH

现在HEAD将位于r1158,并且您的错误修复和新功能都将存在.

Now HEAD will be at r1158 and both your bug fixes and your new feature will be there.

这篇关于与先前的修订版本合并(“回滚"版本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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