如何解决这一 Mercurial 冲突?
我对 Mercurial 和 Python 感到沮丧,因为它们让简单的事情变得困难。我有一个微不足道的冲突,由于 Mercurial 没有给出任何建议,我什至不知道如何解决这个微不足道的文件冲突:
冲突是微不足道的,但如果我不能解决这个问题,我也无法解决任何复杂的事情。我可以按照我想要的方式编辑文件并从任何地方再次提交吗?我应该运行 hg merge
吗?为什么 Mercurial 甚至不能让我选择要保留的版本?为什么如果不深入研究 1000 个写得很糟糕的手册页,一些微不足道的事情几乎不可能完成?
I'm frustrated with Mercurial and Python since it makes easy things difficult. I have a trivial conflict and since Mercurial does not give any suggestion what to do I don't know even how to resolve this trivial file conflict:
The conflict is trivial but if I can't resolve this I can't resolve anything complicated either. Can I just edit the file to a way I want and commit it again from anywhere? Should I run hg merge
? Why can't Mercurial even let me choose a version to keep? Why is something trivial near impossible to do without digging through 1000 poorly written manpages?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要查看KDiff3文档,特别是关于合并和输出窗口。要解决冲突,您需要确定
live
或january
是否是该线路的正确选择。该决定由您做出,没有任何工具可以知道您的意思是其中之一。在 KDiff3 中,按 Ctrl + 2 选择
live
,按 Ctrl + 3 选择一月
或右键单击底部窗口的边缘并选择所需的行。您还可以单击底部窗口并手动编辑该行。Mercurial 让您可以按照自己喜欢的方式配置合并工具。 TortoiseHg 附带一个默认配置,将 KDiff3 置于列表顶部,但如果您愿意,也可以使用其他工具。合并工具实际上只是一个接受四个文件名的程序:要比较的三个文件(基本文件、父文件 1、父文件 2)和一个输出文件名。
要解决命令行上的冲突,您需要启动合适的命令行三向合并工具。例如,如果您愿意,您可以与 vim 合并。 (恐怕我对vimdiff一无所知,我自己使用KDiff3。)
如果您不喜欢看到合并工具弹出,那么您可以设置
让Mercurial仅使用内部三向合并。当编辑不冲突时,它会很好地合并文件。当存在冲突时,文件被标记为“未解决”,并且冲突标记被存储在文件中。
然后,您需要手动编辑该文件以获得您想要的版本。您还可以重新合并并选择本地(您的)版本:
或其他版本:
您可以使用
hg resolve your-file
完全重新启动合并。该文件需要先标记为“已解决”,然后才能提交。这是通过hg resolve --mark your-file
完成的。有关当前合并的状态,请参阅hgsolve --list
。You need to look at the KDiff3 documentation, in particular the section on merging and the output window. To resolve the conflict, you need to decide if
live
orjanuary
is the right choice for the line. That decision is yours to make, no tool can know if you meant one or the other.In KDiff3, you press Ctrl + 2 to select
live
, press Ctrl + 3 to selectjanuary
or right-click in the margin of the bottom window and select the line you want. You can also click in the bottom window and edit the line manually.Mercurial let's you configure your merge tool any way you like. TortoiseHg ships with a default configuration that puts KDiff3 in the top of the list, but you can use another tool if you like. A merge tool is really just a program that accepts four filenames: the three files to compare (base, parent 1, parent 2) and an output file name.
To resolve conflicts on the command-line you need to launch a suitable command-line three-way merge tool. You can for example merge with vim if you like. (I'm afraid I don't know anything about vimdiff, I use KDiff3 myself.)
If you don't like to see merge tools pop up, then you can set
to make Mercurial use the internal three-way merger only. It will merge files fine when the edits are not in conflicts. When there is a conflict, the file is marked as "unresolved" and conflict markers are stored in the file.
You then need to edit the file by hand to get the version you want. You can also re-merge and pick either the local (your) version:
or the other version:
You restart the merge completely with
hg resolve your-file
. The file needs to be marked "resolved" before you can commit it. This is done withhg resolve --mark your-file
. Seehg resolve --list
for the status of the current merge.Base 是您本地系统中的先前版本,
Parent 1 是您当前的更改,
Parent 2 是来自服务器的文件。
如果您需要签入更改,请在合并菜单中的任意位置选择 B。
如果您想在本地计算机上使用最新的服务器版本,请在合并菜单中的所有位置选择 C
Base is the previous version in your local system,
Parent 1 is your current changes,
parent 2 is the file from server.
If you need your changes need to be checked in, select B everywhere in the merge menu.
If you want the latest server version in your local machine, select C everywhere in the merge menu