Mercurial/Meld 中的 3 路合并如何工作?
我正在开发一个项目,其中我有一个提交,该提交引入了一个具有重大问题但尚未立即发现的功能。现在我想完全删除该修订版,同时保持后续工作,但我很难理解这个 3 路合并。这是我的项目的简化图。
o changeset: 134:7f81764aa03a | tag: tip | parent: 128:451d8a19edea | summary: Backed out changeset 451d8a19edea | | @ changeset: 133:5eefa40e2a29 | | summary: (Change I need to keep keep) | | *snip 3 commits* | o changeset: 129:5f6182a97d40 |/ summary: (Change I need to keep keep) | o changeset: 128:451d8a19edea | summary: (Change that introduced a major problem) | o changeset: 127:4f26dc55455d | summary: (summary doesn't matter for this question)
如果我理解正确的话,r127 和 r134 是完全相同的。当我 hg up -C -r 133
然后运行 hg merge
时,Meld 会弹出我的文件之一的三种形式:本地、基本和其他。 local 似乎是 r133,但我很难理解“基础”和“其他”的含义。
I'm working on a project where I have a commit that introduced a feature with major problems that weren't discovered immediately. Now I want to completely remove that revision while keeping the work following it but i'm having a hard time wrapping my head around this 3 way merge. Here is a simplified graph of my project.
o changeset: 134:7f81764aa03a | tag: tip | parent: 128:451d8a19edea | summary: Backed out changeset 451d8a19edea | | @ changeset: 133:5eefa40e2a29 | | summary: (Change I need to keep keep) | | *snip 3 commits* | o changeset: 129:5f6182a97d40 |/ summary: (Change I need to keep keep) | o changeset: 128:451d8a19edea | summary: (Change that introduced a major problem) | o changeset: 127:4f26dc55455d | summary: (summary doesn't matter for this question)
If I understand this correctly, r127 and r134 are exactly the same. When I hg up -C -r 133
and then run hg merge
, Meld pops up with three forms of one of my files: local, base, and other. local seems to be r133 but i'm having a hard time wrapping my head around what "base" and "other" mean.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Local 是 r133
Other 是 r134
Base 是 r128(r133 和 r 134 的共同祖先)
当您执行 3 路合并时,它会进行比较所有这三个因素一起帮助您决定要采取什么以及从哪里采取。通过查看其他版本中的更改以及共同祖先的外观,您可以就保留什么和更改什么做出更明智的决定。
Local is r133
Other is r134
Base is r128 (the common ancestor to both r133 and r 134)
When you perform a 3 way merge it compares all three of those together to help you decide what to take and from where. By seeing what change is in the other revision and what the common ancestor looked like you are able to make a much more informed decision about what to keep and what to change.
你的问题确实令人困惑,但这里有一些信息可能对你有帮助。
基础版本是您当前签出并处理的修订版的未修改版本。可能有其他更改已经分叉(您可以在当前本地和基础之间进行修订!)。它只是最近的修订版,之后没有其他分叉(同一父级)(在您的情况下是 r128) 转移的地方
Head 是版本控制的最新版本。如果您仅单独完成一份副本,那么它可能会是基础的。但是同事可能修改了同一个文件并将其签入版本控制,那么 head 就会晚于你的 base。
Local 是您的修改版本(在您的情况下为 r133)
其他是一些分叉/分支,也将您的 Base 作为父级(在您的情况下为 r134)
三路合并按层次结构工作(至少在融合中)。通常从左到右是这样的:
本地>基数> other / head
local/base 大多是微不足道的,因为它只是您修改的内容
,然后您可以将您的更改合并到 head 修订版或您的同事之一或其他内容中。
可能有多个其他/头部修订,但是合并并不是您的工作,因此超过 3 种方式的比较没有意义。
Your question is really confusing, but here are some information that may help you.
Base is the unmodified version of the revision that you have currently checked out and worked on. where possibly other changes have forked off (you can have revisions in between your current local and base!). its just where the nearest revision where no other fork has diverted from afterwards (same parent) (in your case r128)
Head is the latest revision in version control. if you work alone on only one copy it will probably be base. but a co worker might have modified the same file and checked it into version control, then head is later than your base.
Local is your modified version (in your case r133)
Other is the some fork/branch that has also your Base as parent (in your case r134)
3 way merge works (at least in meld) hierarchically. usually from left to right like this:
local > base > other / head
local/base is mostly trivial because its just what you modified
then you can merge your changes into the head revision or the one of your co worker or whatever.
There can be multiple other/head revisions, but then it's not your job to merge in and therefore more than 3 way compare doesn't make sense.