合并时为什么会出现水银哑音?如何使拉/合并更改更简单? [英] Why is mercurial dumb when merging? How can I make pulling/merging changes simpler?

查看:95
本文介绍了合并时为什么会出现水银哑音?如何使拉/合并更改更简单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用Mercurial,我想我正在尝试做一些非常简单的事情,这应该很典型,但是我对为什么它如此复杂以及为什么它不起作用的方式感到困惑它应该(IMO).

I just started to use Mercurial and I think I'm trying to do something very simple, something that should be quite typical, but I'm stumped on why it's so complicated, and why it doesn't just work the way it should (IMO).

我与朋友共享一些存储库,他进行了一些更改并签入了几个文件并将其推送.现在在svn中,我习惯于更新工作副本并获得他的更改,没有麻烦.但是显然,我必须合并.我不明白的是:应该不是很精明,如果我的朋友进行了最近的更改,而我还没有触摸过文件,那么它应该只使用他的文件版本吗?显然,它无法弄清楚,而是尝试合并完全失败的文件(实际上,我安装了自动打开的Beyond Compare,因此我不能完全归咎于错误的合并).

I share some a repository with a friend, he makes some changes and checks in several files and pushes them. Now in svn I'm used to just updating my working copy and getting his changes, no hassle. But with mercurial apparently I have to merge. What I don't get is: shouldn't mercurial be smart enough to figure out that if my friend made the most recent changes, and I haven't touched the files, that it should just use his version of the file?? Apparently it can't figure that out, and instead it tries to merge the files which utterly fails (actually I have installed Beyond Compare which automatically opened, so I can't blame mercurial entirely for the bad merge).

无论如何,我不知道为什么(对我而言)它应该进行远程(即最新)更改时,甚至必须合并"文件.我在使用该工具的方式上是否做错了什么,还是可以做些什么以使其以更简单的方式工作(我习惯于仅在Subversion中工作的方式)...是否有任何配置?设置,我可以使用命令行标志的任何技巧来使它更好地工作吗?

At any rate, I don't know why it even has to "merge" the files when it's obvious (to me) that it should just have taken the remote (i.e. most recent) changes. Am I doing anything wrong in how I'm using the tool, or is there anything I can do to make it work in a simpler way (the way I'm used to it just working in subversion)... is there any configuration settings, any tips on command line flags I can use to have it work better?

推荐答案

如果您已经在存储库中进行了提交,则只需要合并即可.如果您与朋友共享存储库,那么在您什么都不做的情况下,他会提交一次或多次,当他完成后,您要做的就是拉并更新,不合并.

You only need to merge if you've committed in your repository as well. If you share the repository with your friend, he commits one or more times while you're not doing anything, when he's done all you have to do is pull and update, no merging.

如果您已完成本地提交,则情况将按以下方式展开:

If you've done local commits, here's how the scenario unfolds:

local:    1---2---3---4
central:  1---2---3---4
friend:   1---2---3---4

他承诺:

local:    1---2---3---4
central:  1---2---3---4
friend:   1---2---3---4---5---6

您提交:

local:    1---2---3---4---X---Y
central:  1---2---3---4
friend:   1---2---3---4---5---6

他推动:

local:    1---2---3---4---X---Y
central:  1---2---3---4---5---6
friend:   1---2---3---4---5---6

你拉:

local:    1---2---3---4---X---Y
                       \
                        +-5---6

central:  1---2---3---4---5---6
friend:   1---2---3---4---5---6

您合并:

local:    1---2---3---4---X---Y---7
                       \         /
                        +-5---6-+

central:  1---2---3---4---5---6
friend:   1---2---3---4---5---6

然后您推动并拉动,所有存储库都相同.

Then you push and he pulls, and all the repositories are identical.

但是,如果您在他从事该项目的过程中没有做任何事情,以下是这种情况的展现方式:

However, if you haven't done anything while he has worked on the project, here's how that scenario unfolds:

local:    1---2---3---4
central:  1---2---3---4
friend:   1---2---3---4

他承诺:

local:    1---2---3---4
central:  1---2---3---4
friend:   1---2---3---4---5---6

他推动:

local:    1---2---3---4
central:  1---2---3---4---5---6
friend:   1---2---3---4---5---6

您拉动并更新:

local:    1---2---3---4---5---6
central:  1---2---3---4---5---6
friend:   1---2---3---4---5---6


之所以与Subversion有所不同,是因为有了Subversion,您就有了每个人都必须与之交谈的集中式存储库.


The reason this is different from how Subversion did it is that with Subversion you had the centralized repository that everybody had to talk to.

这样,当您提交本地更改时,Subversion客户端会说对不起,您必须先进行更新才能提交",并且您必须执行该更新.

As such, when you got around to committing your local changes, the Subversion client would say "sorry, you need to update before you can commit", and you had to execute that update.

如果此时您已更改了中央存储库中也已更改的文件,则Subversion会将您的本地更改与服务器更改合并,并始终更新您的修订点.如果没有冲突,则这将是无提示合并,否则您将遇到合并冲突.

If, at that point, you have changed files that are also changed in the central repository, Subversion would merge your local changes with the server changes and update your revision point up to the tip. If there were no conflicts, this would be a silent merge, otherwise you would get merge conflicts.

Mercurial所做的完全相同,只是合并不是静默的.两者都可以在自己的本地存储库中单独提交,而无需彼此交谈,但是当您尝试将所有更改集成到一个公共存储库中时,需要合并. Mercurial永远不会更改现有变更集(除非您使用某些扩展来进行历史记录编辑),因此Mercurial不能自动找出并行变更集如何协同工作.

Mercurial does the exact same thing, except that the merge is not silent. You can both commit individually, in your own local repositories, without ever talking to each other, but when you try to integrate all the changes into one common repository, you need to merge. Mercurial never changes existing changesets (unless you use some extensions for history editing) so it cannot just automatically figure out how your parallell changesets would work together.

如果两个人没有使用相同的文件,或者对相同文件所做的更改没有冲突,那么只需单击几下即可完成合并.

If you two haven't worked on the same files, or the changes you've done to the same files are not in conflict with each other, then the merge is just a few clicks away and you're done.

无论如何,Mercurial有很多选择,但是分布式部分确实改变了您对历史的思考方式.

In any case, Mercurial got many options, but the distributed part really changes how you need to think about your history.

这篇关于合并时为什么会出现水银哑音?如何使拉/合并更改更简单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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