Size: 3133
Comment:
|
Size: 2995
Comment: converted to 1.6 markup
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
#language zh |
|
Line 3: | Line 5: |
In ChineseTutorialExport, we learned how to share a change with another person. But since (as of version 0.7) ["Import"] isn't functional enough to handle emailed merges correctly, we're going to demonstrate merging by pulling from another repository that has made an incompatible change. | 在 ChineseTutorialExport 一节, 我们学会了如何与其他人共享变更. 但是因为(0.7 版本开始) [[Import]] 不能正确的处理通过邮件发送的合并, 我们要演示如何从其他做了不兼容变更的仓库用拖合并。 |
Line 5: | Line 7: |
First, we must create something to merge. Let's ["Clone"] the {{{my-hello}}} repository again: | 首先, 我们必须创建合并的目标. 我们再次 [[Clone]] {{{my-hello}}}的仓库: |
Line 12: | Line 14: |
We are going to give {{{hello.c}}} a description in its comment section. | 我们给 {{{hello.c}}} 的注释段加一段描述. |
Line 19: | Line 21: |
Let's change the second line from this: | 我们将第二行: |
Line 25: | Line 27: |
to this: | 改为: |
Line 31: | Line 33: |
Let's save and quit the editor, and ["Commit"] our change. This time, we save some time by using the {{{-m}}} option to the {{{commit}}} command, to spare us from being dropped into an editor: | 我们存档并退出编辑器, 然后 [[Commit]] 我们的变更. 这次, 我们在{{{commit}}}命令中使用{{{-m}}} 选项来节省时间, 以免我们又要进入编辑器: |
Line 37: | Line 39: |
At this point, we have made one change to {{{hello.c}}} in the {{{my-hello-new-output}}} [:Repository:仓库], and another change to {{{hello.c}}} in the {{{my-hello-desc}}} [:Repository:仓库]. How do we ''merge'' these two diverging lines of development? Will there be a problem when we want to pull from one into the other? | 这时, 我们已经对 {{{my-hello-new-output}}} [[Repository|仓库]]中的 {{{hello.c}}} 作了一个变更 , 同时对 {{{my-hello-desc}}} [[Repository|仓库]] 中的 {{{hello.c}}} 作了另一个变更. 我们怎样 ''merge'' 这两个分叉开发主线? 我们从一个仓库拖进另外一个仓库的时候会出现问题吗? |
Line 39: | Line 41: |
This works just fine. While still in {{{my-hello-desc}}}, let's ["Pull"] the changes from {{{my-hello-new-output}}} and see what happens: | 这完全没有问题. 现在仍然在 {{{my-hello-desc}}}中, 我们从 {{{my-hello-new-output}}}中 [[Pull]] 并且看看发生了什么: |
Line 52: | Line 54: |
This looks just like the output of {{{pull}}} from TutorialShareChange! So all we have to do is an ["Update"] now, right? | 这看起来像 TutorialShareChange! 中 {{{pull}}} 的输出,所以我们现在要进行[[Update]]了, 对吧? |
Line 62: | Line 64: |
Nope. Something has happened. ["Mercurial"] is telling us that we must ["Merge"] the changes that we made in each [:Repository:仓库]. This sounds painful, right? It's actually very easy. Let's follow the instructions of the last line of output: | 噢,好像发生了什么事情. [[Mercurial]] 告诉我们必须 [[Merge]]每个 [[Repository|仓库]] 中的变更. 看起来有点麻烦, 对吗? 其实很简单. 现在我们按照输出最后一行的指令执行: |
Line 69: | Line 71: |
That's all there is to it! ["Mercurial"] was able to handle the merge automatically for you, by calling under the covers the {{{hgmerge}}} script (or whatever is your MergeProgram). Depending on your environment, the `hgmerge` may call a graphical merge resolver tool. If we look at {{{hello.c}}}, we find that it contains ''both'' the change from {{{my-hello-new-output}}} and the change from {{{my-hello-desc}}}. | 这就完成了! 通过调用{{{hgmerge}}}脚本(或者你自己定义的合并程序),[[Mercurial]]可以自动的替你完成合并. Depending on your environment, the `hgmerge` may call a graphical merge resolver tool. If we look at {{{hello.c}}}, we find that it contains ''both'' the change from {{{my-hello-new-output}}} and the change from {{{my-hello-desc}}}. |
Line 76: | Line 78: |
---- CategoryChinese |
教程 - 合并改变
在 ChineseTutorialExport 一节, 我们学会了如何与其他人共享变更. 但是因为(0.7 版本开始) Import 不能正确的处理通过邮件发送的合并, 我们要演示如何从其他做了不兼容变更的仓库用拖合并。
首先, 我们必须创建合并的目标. 我们再次 Clone my-hello的仓库:
$ cd .. $ hg clone my-hello my-hello-desc
我们给 hello.c 的注释段加一段描述.
$ cd my-hello-desc $ vi hello.c
我们将第二行:
* hello.c
改为:
* hello.c - hello, world
我们存档并退出编辑器, 然后 Commit 我们的变更. 这次, 我们在commit命令中使用-m 选项来节省时间, 以免我们又要进入编辑器:
$ hg commit -m 'Add description of hello.c'
这时, 我们已经对 my-hello-new-output 仓库中的 hello.c 作了一个变更 , 同时对 my-hello-desc 仓库 中的 hello.c 作了另一个变更. 我们怎样 merge 这两个分叉开发主线? 我们从一个仓库拖进另外一个仓库的时候会出现问题吗?
这完全没有问题. 现在仍然在 my-hello-desc中, 我们从 my-hello-new-output中 Pull 并且看看发生了什么:
$ hg pull ../my-hello-new-output pulling from ../my-hello-new-output searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) (run 'hg update' to get a working copy)
这看起来像 TutorialShareChange! 中 pull 的输出,所以我们现在要进行Update了, 对吧?
$ hg update this update spans a branch affecting the following files: hello.c (resolve) aborting update spanning branches! (use 'hg merge' to merge across branches or 'hg update -C' to lose changes)
噢,好像发生了什么事情. Mercurial 告诉我们必须 Merge每个 仓库 中的变更. 看起来有点麻烦, 对吗? 其实很简单. 现在我们按照输出最后一行的指令执行:
$ hg merge merging hello.c
这就完成了! 通过调用hgmerge脚本(或者你自己定义的合并程序),Mercurial可以自动的替你完成合并. Depending on your environment, the hgmerge may call a graphical merge resolver tool. If we look at hello.c, we find that it contains both the change from my-hello-new-output and the change from my-hello-desc.
(Note: before Mercurial version 0.9, hg update -m should have been used in place of hg merge).
When working with changes made by other people, this is the kind of merge you will end up performing most of the time.
Let us continue on, however, and learn how to deal with situations where conflicting changes have been made in ChineseTutorialConflict.