本文介绍了非冲突变更示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试了解 subversion 合并命令的详细信息.我认为,了解也是冲突的变更与非冲突的变更之间的区别会有所帮助.

I'm trying to understand the details of the subversion merge commands. I think understanding the difference between a change that is also a conflict and a change that is not a conflict would help.

这是此线程的后续.

推荐答案

冲突是指两个人都对同一个文件进行了更改,但无法自动解决这两个更改.

A change that is a conflict is when 2 people have both made a change to the same file in such a way that the two changes can not be automatically resolved.

1) 让我们从一个非冲突合并的例子开始.

原始文件

line1
line2
line3

A 将其更改为:

line1CHANGED
line2
line3

B 把它改成这样:

line1
line2CHANGED
line3

当它们都被签入并合并时,就不会有冲突,因为它可以轻松解决生成这个最终文件:

When those are both checked in and merged, there is no conflict because it can easily resolve to produce this final file:

line1CHANGED
line2CHANGED
line3

Subversion 会自动将其作为合并处理.

Subversion will handle this automatically as a merge.

2) 现在是冲突更改的示例.

原始文件

line1
line2
line3

A 将其更改为:

line1CHANGED_BY_A
line2
line3

B 把它改成这样:

line1CHANGED_BY_B
line2
line3

这个不能自动合并,所以是冲突.您需要通过接受 A 的更改或 B 的更改来解决.在这种情况下,subversion 会警告您发生冲突,并要求您决定如何解决这些冲突.

This can't be merged automatically, so it is a conflict. You will need to resolve, either by accepting person A's change or person B's change. In this case subversion will warn you of conflicts and require a decision from you on how to resolve them.

3) 最后,您可以在同一修订版中同时包含冲突和非冲突更改.

原始文件

line1
line2
line3

A 将其更改为:

line1CHANGED_BY_A
line2ALSO_CHANGED_BY_A
line3

B 把它改成这样:

line1CHANGED_BY_B
line2
line3ALSO_CHANGED_BY_B

现在,在这个例子中,两个人都更改了文件,并且必须解决第 1 行的冲突更改,但第 2 行 &3 是不冲突的更改,可以自动解决.

Now, with this example, both people have changed the file, and there is a conflicting change on line 1 that must be resolved, but lines 2 & 3 are non-conflicting changes and can be resolved automatically.

您可以选择通过多种方式解决此问题.

You can choose to resolve this in several ways.

首先,您可以完全接受 A 或 B 的文件并丢弃另一个.这将导致其他人的非冲突更改丢失.假设您选择使用 A 完全解析,您的最终文件将是:

Firstly, you can fully accept either A's or B's file and discard the other. This would result in the other persons non-conflicting changes being lost. Say, you choose to fully resolve using A, your final file would be:

line1CHANGED_BY_A
line2ALSO_CHANGED_BY_A
line3

(正好是A的文件,B的所有改动都被丢弃)

(Exactly A's file, and all changes by B are discarded)

其次,您可以只解决冲突的更改,而仍然保留所有非冲突的更改.这是您将为第一行选择 A 或 B 的更改,并且仍然从两个人那里获得另一行的更改.因此,例如您选择使用 A 解决冲突,您的最终文件将是:

Secondly, you can resolve only the conflicting changes, and still retain all the non-conflicting changes. This was you would choose either A's or B's change for the first line, and still get both of the other line's changes, from both people. So, say for example you choose to resolve conflicts using A, your final file would be:

line1CHANGED_BY_A
line2ALSO_CHANGED_BY_A
line3ALSO_CHANGED_BY_B

或者,您可以使用诸如 KDiff 之类的工具来支持单独审查每个冲突(因为当然您可以拥有多个更改,冲突和非冲突,都在同一个文件中),这将允许您为每个更改选择不同的解决方法.

Alternative you can use tools like KDiff that support reviewing of each conflict separately (because of course you can have mutliple changes, both conflicting and non-conflicting, within the same file), which will allow you to select different methods of resolution for each.

如果您在理解与命令行工具合并时遇到问题,我强烈建议您查看 KDiff(或其他一些 GUI 合并/差异工具),因为它们将文件并排显示(连同原始文件)并允许您可以直观地看到每个解决方案的作用.

If you are having trouble understanding merging with the command line tools I strongly recommend you take a look at KDiff (or some other GUI merge/diff tool) as they display the files alongside each other (along with the original) and allow you to visual what each resolution action would do.

这篇关于非冲突变更示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 01:33