如何使用 meld 设置 svn 冲突解决?

发布于 2024-12-02 11:27:14 字数 253 浏览 0 评论 0 原文

我已在 Subversion 配置中指定 merge-tool-cmd = meld。当我使用所提供的冲突解决选项中的选项 l 解决合并冲突时,我收到消息:

meld: error: too many arguments (wanted 0-4, got 5)
The external merge tool exited with exit code 2

任何人都可以诊断问题/提供解决方案吗?谢谢。

I've specified merge-tool-cmd = meld in my Subversion config. When I go to resolve a merge conflict using option l from the presented conflict resolution options, I receive the message:

meld: error: too many arguments (wanted 0-4, got 5)
The external merge tool exited with exit code 2

Can anyone diagnose the problem/provide a solution? Thanks.

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

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

发布评论

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

评论(4

橙幽之幻 2024-12-09 11:27:14

首先警告!如果您犯了这个错误,很容易最终丢失您的本地编辑!测试测试测试!

我担心 pmod 链接中的脚本不适用于 svn 1.6(当前在 Ubuntu 11.04 中)。将 pmod 链接中的代码放在一起和 这里和建议在这里,我制作了这个似乎可以正常工作的脚本:

#!/usr/bin/env python
# svn merge-tool python wrapper for meld
import sys
import subprocess

try:
   # path to meld
   meld = "/usr/bin/meld"

   # file paths
   base   = sys.argv[1]
   theirs = sys.argv[2]
   mine   = sys.argv[3]
   merged = sys.argv[4]

   # the call to meld
   # For older meld versions:
   # cmd = [meld, mine, base, theirs, merged]
   # New meld versions: >= 1.8.4
   cmd = [meld, mine, base, theirs, '-o', merged]

   # Call meld, making sure it exits correctly
   subprocess.check_call(cmd)
except:
   print "Oh noes, an error!"
   sys.exit(-1)

将其保存在合理的地方(例如/usr/local/bin/svn-merge-meld.py)并使其可执行:

sudo chmod +x /usr/local/bin/svn-merge-meld.py

然后编辑 ~/.subversion/config 并取消注释 merge-tool-cmd = 行,并设置命令的路径。

请注意,当发生冲突时,系统会提示您如何处理。您需要输入一个 l 并让 svn 运行此脚本。完成合并后,您需要键入 r 来解决冲突并将合并的版本复制到工作副本。

First a warning! It is very easy to end up losing your local edits if you get this wrong! Test test test!

I'm afraid the script from pmod's link does not work with svn 1.6 (current in Ubuntu 11.04). Putting together code from pmod's link and here and advice here, I made this script that seems to work ok:

#!/usr/bin/env python
# svn merge-tool python wrapper for meld
import sys
import subprocess

try:
   # path to meld
   meld = "/usr/bin/meld"

   # file paths
   base   = sys.argv[1]
   theirs = sys.argv[2]
   mine   = sys.argv[3]
   merged = sys.argv[4]

   # the call to meld
   # For older meld versions:
   # cmd = [meld, mine, base, theirs, merged]
   # New meld versions: >= 1.8.4
   cmd = [meld, mine, base, theirs, '-o', merged]

   # Call meld, making sure it exits correctly
   subprocess.check_call(cmd)
except:
   print "Oh noes, an error!"
   sys.exit(-1)

Save this somewhere sensible (eg /usr/local/bin/svn-merge-meld.py) and make it executable:

sudo chmod +x /usr/local/bin/svn-merge-meld.py

Then edit ~/.subversion/config and uncomment the line merge-tool-cmd =, and set the path to your command.

Note that when a conflict occurs, you will be prompted what to do with it. You need to type a single l and for svn to run this script. When you've finished your merge, you need to type an r to resolve the conflict and copy the merged version to the working copy.

时光礼记 2024-12-09 11:27:14

drevicko 的答案是正确的,但需要 Python。这个答案是 脚本替代方案:

#!/bin/bash

base=${1?1st arg is the 'base' file}
theirs=${2?2nd arg is 'theirs' file}
mine=${3?3rd arg is 'mine' file}
merged=${4?4th arg is the 'merged' file}

cat "$mine" > "$merged"

meld -L "Base=${base##*/}"           "$base"   \
     -L "Mine->Merged=${merged##*/}" "$merged" \
     -L "Theirs=${theirs##*/}"       "$theirs" \
     -o "$merged"

复制上面的内容文件 svn-merge-meld.sh 中的脚本并提供执行权限:

chmod +x svn-merge-meld.sh

最后编辑您的 配置:

vi ~/.subversion/config

并启用 merge-tool-cmd

[helpers]
merge-tool-cmd = /path/to/svn-merge-meld.sh

The drevicko's answer is correct but requires Python. This answer is a script alternative:

#!/bin/bash

base=${1?1st arg is the 'base' file}
theirs=${2?2nd arg is 'theirs' file}
mine=${3?3rd arg is 'mine' file}
merged=${4?4th arg is the 'merged' file}

cat "$mine" > "$merged"

meld -L "Base=${base##*/}"           "$base"   \
     -L "Mine->Merged=${merged##*/}" "$merged" \
     -L "Theirs=${theirs##*/}"       "$theirs" \
     -o "$merged"

Copy the above script in file svn-merge-meld.sh and provide execution permission with:

chmod +x svn-merge-meld.sh

Finally edit your configuration:

vi ~/.subversion/config

and enable merge-tool-cmd:

[helpers]
merge-tool-cmd = /path/to/svn-merge-meld.sh
寄居人 2024-12-09 11:27:14

您需要使用包装器脚本来抓取并按照 diff 工具所需的顺序放置 subversion 的内容(检查 这个):

使用外部二路和三路差分工具(其他
当然,与 GNU diff 和 diff3 相比)Subversion 是使用包装脚本,它
将 Subversion 的输入转换为您可以使用的内容
差分工具可以理解,然后将输出转换为
你的工具恢复成 Subversion 期望的格式——这种格式
GNU 工具会使用。
...

Subversion 使用适合的参数调用外部 diff 程序
GNU diff 实用程序,并且只期望外部程序将
返回成功的错误代码。对于大多数替代差异
程序,只有第六和第七个参数——文件的路径
分别代表差异的左侧和右侧 - 是
感兴趣。

此处对此进行了很好的描述

You need to use wrapper script to grab and put things subversion is out to the order needed for your diff tool (check this):

The key to using external two- and three-way differencing tools (other
than GNU diff and diff3, of course) with Subversion is to use wrapper scripts, which
convert the input from Subversion into something that your
differencing tool can understand, and then to convert the output of
your tool back into a format that Subversion expects—the format that
the GNU tools would have used.
...

Subversion calls external diff programs with parameters suitable for
the GNU diff utility, and expects only that the external program will
return with a successful error code. For most alternative diff
programs, only the sixth and seventh arguments—the paths of the files
that represent the left and right sides of the diff, respectively—are
of interest.

This is very well described here

七度光 2024-12-09 11:27:14

我更新了 @drevicko 答案以使用 subversion>=1.14、meld>=3.20 和 Python 3:

#!/usr/local/bin/python3

# svn merge-tool python wrapper for meld
import sys
import subprocess

try:
   # path to meld
   meld = "/usr/bin/meld"

   # file paths
   base    = sys.argv[1]
   theirs  = sys.argv[2]
   mine    = sys.argv[3]
   merged1 = sys.argv[4]
   merged2 = sys.argv[5]

   print(14*"*" + " MELD was called with " + 14*"*")
   print(f"base    = {base}")
   print(f"theirs  = {theirs}")
   print(f"mine    = {mine}")
   print(f"merged1 = {merged1}")
   print(f"merged2 = {merged2}")

   # the call to meld
   cmd = [meld, mine, base, theirs, '-o', merged1, '--auto-merge', '-L', 'mine -> base(merged) <-theirs']

   # Call meld, making sure it exits correctly
   subprocess.check_call(cmd)
except Exception:
   print("There was an error calling meld!")
   sys.exit(-1)

print(50*"*")

I updated @drevicko answer to work with subversion>=1.14, meld>=3.20 and Python 3:

#!/usr/local/bin/python3

# svn merge-tool python wrapper for meld
import sys
import subprocess

try:
   # path to meld
   meld = "/usr/bin/meld"

   # file paths
   base    = sys.argv[1]
   theirs  = sys.argv[2]
   mine    = sys.argv[3]
   merged1 = sys.argv[4]
   merged2 = sys.argv[5]

   print(14*"*" + " MELD was called with " + 14*"*")
   print(f"base    = {base}")
   print(f"theirs  = {theirs}")
   print(f"mine    = {mine}")
   print(f"merged1 = {merged1}")
   print(f"merged2 = {merged2}")

   # the call to meld
   cmd = [meld, mine, base, theirs, '-o', merged1, '--auto-merge', '-L', 'mine -> base(merged) <-theirs']

   # Call meld, making sure it exits correctly
   subprocess.check_call(cmd)
except Exception:
   print("There was an error calling meld!")
   sys.exit(-1)

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