macos 如何使用 p4merge 作为 Mercurial 的合并/差异工具?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42980/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 05:52:59  来源:igfitidea点击:

How to use p4merge as the merge/diff tool for Mercurial?

macosconfigurationmercurialperforcep4merge

提问by Jay Stramel

Does anyone know how to setup Mercurialto use p4mergeas the merge/diff tool on OS X 10.5?

有谁知道如何设置Mercurial以使用p4merge作为 OS X 10.5 上的合并/差异工具?

回答by Ry4an Brase

This will work for merging:

这将适用于合并:

Place this into your ~/.hgrc(or, optionally, your Mercurial.inion Windows):

将其放入您的~/.hgrc(或者,可选地,您Mercurial.ini在 Windows 上):

[merge-tools]
p4.priority = 100
p4.premerge = True  # change this to False if you're don't trust hg's internal merge
p4.executable = /Applications/p4merge.app/Contents/MacOS/p4merge
p4.gui = True
p4.args = $base $local $other $output

Requires Mercurial 1.0 or newer. Clearly you'll need to update the path to that executable to reflect where you'd got p4merge installed.

需要 Mercurial 1.0 或更新版本。显然,您需要更新该可执行文件的路径以反映您安装 p4merge 的位置。



You can't change what hg diffuses; but you canuse the extdiffextension to create new diff commands that use the display you want.

您无法更改hg diff使用的内容;但是您可以使用extdiff扩展来创建使用您想要的显示的新差异命令。

So hg pdiffcould run p4 merge, etc.

所以hg pdiff可以运行 p4 合并等。

回答by Ivan

I found Ry4an's answerto be a good solution, except for a minor problem, which left p4merge (under mac os) mixing up the command inputs. Do everything described in his answerand add the following line in the [merge-tools] section:

我发现Ry4an 的答案是一个很好的解决方案,除了一个小问题,它让 p4merge(在 mac os 下)混淆了命令输入。执行他的回答中描述的所有操作,并在 [merge-tools] 部分添加以下行

p4.args=$base $local $other $output

This line tells mercurial in which order p4merge takes its arguments.

这一行告诉 mercurial p4merge 接受它的参数的顺序。

回答by macrobug

I am using version 1.0.1 of TortoiseHg and p4merge works out of the box.

我使用的是 TortoiseHg 的 1.0.1 版,p4merge 开箱即用。

Just go to Global Settings -> TortoiseHgand select the following options:

只需转到全局设置 -> TortoiseHg并选择以下选项:

  • Three-way Merge Tool: p4merge
  • Visual Diff Tool: p4merge
  • 三路合并工具:p4merge
  • 视觉差异工具:p4merge

Screenshot

Screenshot

回答by gnz

Maybe because I'm working on Windows, but the proposed solution didn't work for me. Instead, the following does work.

也许是因为我在 Windows 上工作,但建议的解决方案对我不起作用。相反,以下确实有效。

In your ~/.hgrc// Mercurial.ini, I applied the following changes:

在您的~/.hgrc// 中Mercurial.ini,我应用了以下更改:

Enabled "ExtDiff" extension:

启用“ExtDiff”扩展:

[extensions]
hgext.extdiff =

Added P4 extdiff command:

添加了 P4 extdiff 命令:

[extdiff]
cmd.p4diff = p4merge

Configured it as the default visual diff tool:

将其配置为默认的视觉差异工具:

[tortoisehg]
vdiff = p4diff

回答by Matthew Schinckel

I'm guessing there's a CLI tool for p4merge (which I know nothing about).

我猜有一个用于 p4merge 的 CLI 工具(我对此一无所知)。

I wrote a blog post about using Changes.app, and some other GUI tools with Mercurial: Using Mercurial with GUI Tools.

我写了一篇关于使用 Changes.app 和其他一些带有 Mercurial 的 GUI 工具的博客文章:使用 Mercurial 和 GUI 工具。

Basically, you need to know the calling expectations of the CLI tool that loads up the diff tool. IE, how to make it load data from a particular file, and how to make it wait for exit. There should be enough info on the post to give you some ideas.

基本上,您需要知道加载 diff 工具的 CLI 工具的调用期望。IE,如何让它从特定文件加载数据,以及如何让它等待退出。帖子上应该有足够的信息给你一些想法。

回答by Matthew Schinckel

I use the following bit of Python to launch p4merge and use it with git :

我使用以下 Python 代码来启动 p4merge 并将其与 git 一起使用:

#!/usr/bin/python
import sys
import os

os.system('/Applications/p4merge.app/Contents/MacOS/p4merge "%s" "%s"' % (sys.argv[2], sys.argv[5]))

I'm not sure how mercurial looks to launch an external diff tool though ? Hopefully it's as simple as adjusting 2 & 5 in the above line to being the index of the arguments for 'checked in' and 'current working copy'.

我不确定 mercurial 看起来如何启动外部差异工具?希望它就像将上面一行中的 2 和 5 调整为“签入”和“当前工作副本”参数的索引一样简单。