使用中央存储库时,善变协作会导致多次提交相同的更改

发布于 2024-11-03 14:16:24 字数 558 浏览 0 评论 0原文

我一直在使用 Mercurial 和中央存储库。当我们两个或两个以上的人致力于改变时,我们会在本地做出承诺。在某些时候,我们会将这些更改推送回中央存储库。

当我拉动时,问题就出现了。通常,有些文件是由其他开发人员修改和推送的,然后通过拉取将这些文件下载到我的存储库中。然后我需要合并,这显示了我的本地存储库和已提交的文件之间的差异。

困扰我的是我必须合并和提交。它被推回到中央服务器,该服务器似乎已经提交了两次相同的更改,一次作为我的合并,一次作为来自其他开发人员的变更集。

Mercurial 中是否有某种方法可以更新我的存储库并更新我未触及的文件,而不是记录完全相同的更改两次,一次来自原始开发人员,一次在我的合并中?

这个问题似乎提出了同样的观点,但没有提供我的问题的答案: 为什么 Mercurial 是愚蠢的合并时?如何使拉取/合并更改变得更简单?

I've been using mercurial with a central repository. As two or more of us work on changes we commit locally. At some point we push these changes back to the central repository.

The problem comes in when I do a pull. Often there are files that were modified and pushed by another developer and those come down to my repository with a pull. I am then required to merge, which shows me the difference between my local repository and the files that were committed.

What bothers me is that I have to merge and commit. That gets pushed back up to the central server which appears to have committed the same changes twice, once as me as a merge and once as a changeset from the other developer.

Is there some way in mercurial to update my repository and have files that I haven't touched just be updated rather than recording the exact same change twice, once from the original developer and once in my merge?

This question seems to raise the same point, but doesn't provide an answer to my question:
Why is mercurial dumb when merging? How can I make pulling/merging changes simpler?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

-柠檬树下少年和吉他 2024-11-10 14:16:24

Mercurial 的工作方式是变更集和修订。

变更集是进行修订时所做的更改的快照。

如果您成功地仅更新了已更改的文件,那么当您拉取时,您的工作文件夹中将不会有实际的修订版,您将拥有一个混蛋修订版,并且只有您和您的机器知道它是如何发生的是。在不同时间拉动的其他人会得到不同的混蛋修订版,他们不会排队。

所以不,Mercurial 的设计工作方式与您所说的完全一样,只是它并没有真正显示发生了两次的更改,如果它看起来这样做,则一定是您做错了什么。

换句话说,如果我更改某些内容并提交,然后我拉下您的更改,进行合并并提交,合并提交将仅包含我必须执行的所有更改才能解决合并问题。如果合并是自动的,没有需要解决的冲突,那么看起来您只是提交了一个具有两个父级的空变更集。

现在,有一些方法可以减轻所有分支的影响,例如您可以使用 rebase。

会发生以下情况:

central: 1---2---3---4

local:   1---2---3---4

您更改某些内容

central: 1---2---3---4

local:   1---2---3---4---5

,其他人更改某些内容,然后推送:(

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

local:   1---2---3---4---5

我在 5 之后使用 ' 来表明虽然该存储库中的修订号为 5,但它与其他存储库中的修订号 5 不同.)

然后当你拉动时,它看起来像这样:

central: 1---2---3---4---5'--6'  <-- corresponds to these <--+
                                                             |
local:   1---2---3---4---5                                   |
                      \                                      |
                       6'---7'   <-- note that these gets renumbered

然后你将 5 变基到 7' 之上,你会得到这样的结果:

local:   1---2---3---4---6'--7'--5

如果需要,如果你做了冲突的更改,那么当你变基时会发生合并。 rebase之后就可以push了。它基本上让你的修订历史看起来像是你轮流工作。

Mercurial works in terms of changesets and revisions.

A changeset is a snapshot of the changes that went into making a revision.

If you were to succeed in only updating the files that were changed, when you pulled, you wouldn't have an actual revision in your working folder, you would have a bastard revision, and only you and your machine would know how that came to be. Someone else that pulls at a different time would get a different bastard revision, and they wouldn't line up.

So no, Mercurial is designed to work exactly like you say it does, except that it doesn't really show the changes as happening twice, there must be something you're doing wrong if it appears to do that.

In other words, if I change something, and commit, then I pull down your changes, do a merge, and commit that, the merge commit would only contain any changes I have to do in order to resolve the merge. If the merge was automatic, no conflicts that needed to be resolved, it would look like you're just committing an empty changesets, with two parents.

Now, there are ways to mitigate all the branches, you can use rebase for instance.

What would happen is the following:

central: 1---2---3---4

local:   1---2---3---4

You change something

central: 1---2---3---4

local:   1---2---3---4---5

Someone else changes something, and push:

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

local:   1---2---3---4---5

(I use ' after the 5 to show that while it is revision number 5 in that repository, it's not the same as revision number 5 in the other repository.)

Then when you pull, it looks like this:

central: 1---2---3---4---5'--6'  <-- corresponds to these <--+
                                                             |
local:   1---2---3---4---5                                   |
                      \                                      |
                       6'---7'   <-- note that these gets renumbered

Then you rebase 5 to be on top of 7', and you get this:

local:   1---2---3---4---6'--7'--5

if needs be, a merge happens when you rebase, if you have done conflicting changes. After the rebase, you can push. It basically makes your revision history look like you took turns working.

江南烟雨〆相思醉 2024-11-10 14:16:24

简短的回答是“不用担心”。在您看来,那个人所做的更改是您在后续合并中再次完成的,但这只是因为“diff”没有很好的方法来在任何 VCS 中显示合并。改变是他们的,组合是你的,一切都会顺利进行。起诉 DVCS 的两个人最终会留下一段看起来像编织绳的历史,但这没关系。

The short answer is "don't worry about it". It looks to you like the change that person did is again done by you in a subsequent merge, but that's just because 'diff' doesn't have a great way to show merges in any VCS. The change is theirs, the combination is yours, and the whole thing works out. Two people suing a DVCS end up with a history that looks like a braided rope, and that's okay.

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