macos 配置 Mercurial - Apple Mac OS X 的 FileMerge

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1304121/
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 06:20:51  来源:igfitidea点击:

Configuring Mercurial - FileMerge for Apple Mac OS X

configurationmercurialmacosfilemerge

提问by Frank V

How do I configure Apple's FileMerge program to function as Mercurial's merge tool? I have my .hgrc file setup in my home directory and I simply want to configure FileMerge as the merge program.

如何将 Apple 的 FileMerge 程序配置为 Mercurial 的合并工具?我的主目录中有 .hgrc 文件设置,我只想将 FileMerge 配置为合并程序。

回答by Ned Deily

As described in the hg wiki, this has worked for me with various versions of hg:

hg wiki中所述,这对我适用于各种版本的 hg:

  • Create a script somewhere in your $PATH, say in /usr/local/bin:
  • 在您的某处创建一个脚本$PATH,例如/usr/local/bin
$ vim /usr/local/bin/opendiff-w

#!/bin/sh
# opendiff returns immediately, without waiting for FileMerge to exit.
# Piping the output makes opendiff wait for FileMerge.
opendiff "$@" | cat
$ vim /usr/local/bin/opendiff-w

#!/bin/sh
# opendiff returns immediately, without waiting for FileMerge to exit.
# Piping the output makes opendiff wait for FileMerge.
opendiff "$@" | cat
  • Add the following sections to your ~/.hgrc:
  • 将以下部分添加到您的~/.hgrc:
[extdiff]
cmd.interdiff = hg-interdiff
cmd.opendiff = opendiff-w

[merge-tools]
filemerge.executable = opendiff-w
filemerge.args = $local $other -ancestor $base -merge $output

[extensions]
extdiff = 
[extdiff]
cmd.interdiff = hg-interdiff
cmd.opendiff = opendiff-w

[merge-tools]
filemerge.executable = opendiff-w
filemerge.args = $local $other -ancestor $base -merge $output

[extensions]
extdiff = 

Now you can use it as $hg opendiff.

现在您可以将其用作$hg opendiff.

回答by quark

Update: The Mercurial wiki has a page about FileMerge. Read that first.

更新:Mercurial wiki 有一个关于 FileMerge页面。先读那个。

I haven't tried to use FileMergebut a general overview might help. Most of what you want to know is described at the Mercurial wiki's MergeProgrampage. The short version is your typical choices are:

我没有尝试使用,FileMerge但一般概述可能会有所帮助。您想知道的大部分内容都在 Mercurial wiki 的MergeProgram页面中进行了描述。简短版本是您的典型选择:

Set the HGMERGEenvironment variable to point at the merge tool you want.

HGMERGE环境变量设置为指向所需的合并工具。

or, add the following to your .hgrc:

或者,将以下内容添加到您的.hgrc

 [ui]
 merge = /path/to/toolname

 [merge-tools]
 toolname.args = $base $local $other

The key is that a merge tool needs to take three arguments: the base revision, your local changes, and the changes from the other branch. You use the first configuration to specify the tool, and the second to specify how it takes arguments.

关键是合并工具需要接受三个参数:基本修订、本地更改和来自其他分支的更改。您使用第一个配置指定工具,第二个配置指定它如何接受参数。

回答by Arkaaito

None of the documentation linked worked for me without modifications; eventually what I ended up doing was a combination of the official instructionsand "Using Vim as the filemerge program" from https://www.mercurial-scm.org/wiki/TipsAndTricks. I created the opendiff-w script described in this answer(though I named it hgvdiff), and put the following into my .hgrc:

未经修改,链接的任何文档都不适用于我;最终我最终做的是结合官方说明https://www.mercurial-scm.org/wiki/TipsAndTricks 中的“使用 Vim 作为文件合并程序” 。我创建了此答案中描述的 opendiff-w 脚本(尽管我将其命名为 hgvdiff),并将以下内容放入我的 .hgrc 中:

[extdiff]
cmd.interdiff = hg-interdiff
cmd.opendiff = /usr/local/bin/hgvdiff

[merge-patterns]
** = filemerge

[merge-tools]
filemerge.executable = /usr/local/bin/hgvdiff
filemerge.args = $local $other -ancestor $base -merge $output
filemerge.checkchanged = true
filemerge.gui = true

[extensions]
extdiff =

This is moderately functional, though it sometimes performs the check for whether a file was changed prematurely, leading to a bunch of:

这是中等功能,尽管它有时会检查文件是否过早更改,导致一堆:

 output file wwwroot/zoomingo/website/protected/messages/en/z.php appears unchanged
was merge successful (yn)? n

when you close FileMerge.

当您关闭 FileMerge 时。

回答by kernix

Here is how I fixed it:

这是我修复它的方法:

Created /usr/local/bin/opendiff-wfilled with:

创建/usr/local/bin/opendiff-w充满:

#!/bin/sh
# opendiff returns immediately, without waiting for FileMerge to exit.
# Piping the output makes opendiff wait for FileMerge.
opendiff "$@" | cat

Then ran the command: sudo chmod +x /usr/local/bin/opendiff-w

然后运行命令: sudo chmod +x /usr/local/bin/opendiff-w

Then edited ~/.hgrcwith the following addition:

然后编辑~/.hgrc了以下内容:

[extdiff]
cmd.interdiff = hg-interdiff
cmd.opendiff = opendiff-w

[merge-tools]
filemerge.executable = /usr/local/bin/opendiff-w
filemerge.args = $local $other -ancestor $base -merge $output

[extensions]
extdiff = 

Then I ran the following command to check wether it worked: hg opendiff

然后我运行以下命令来检查它是否有效: hg opendiff

However, I got the following error:

但是,我收到以下错误:

exception raised trying to run FileMerge: launch path not accessible

In order to fix it I ran the following command:

为了修复它,我运行了以下命令:

sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer/

This should now work and open up FileMerge.

这现在应该可以工作并打开 FileMerge。

====================================================================

================================================== ==================

If you're using TorsoiseHg for Mac, the only thing you need to do now in order to work with FileMerge is to choose filemerge from the Detected merge/diff tools when the Resolve Conflict window appears and choose Tool Resolve.

如果您使用的是 Mac 版 TorsoiseHg,那么现在为了使用 FileMerge,您唯一需要做的就是在出现解决冲突窗口时从检测到的合并/差异工具中选择文件合并,然后选择工具解决。

enter image description here

在此处输入图片说明

Hope this helps.

希望这可以帮助。

回答by wadesworld

I haven't tried it, but I'm betting you need to point all the way to the FileMerge executable, not just the app bundle.

我还没有尝试过,但我打赌您需要一直指向 FileMerge 可执行文件,而不仅仅是应用程序包。

So:

所以:

[ui]  
merge = /Developer/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge