如果应用失败,如何在mercurial中应用补丁并显示diff工具

时间:2011-11-04 07:43:23

标签: python mercurial patch

我想在Mercurial中应用补丁:

hg import patch_name.patch

但如果我收到错误abort: patch failed to apply,Mercurial会创建*.rej个文件。

是否有办法显示kdiff或vim-diif来纠正冲突。

2 个答案:

答案 0 :(得分:3)

没有办法做到这一点。建议的方法是打开文件和.rej文件,并手动合并被拒绝的帅哥。

答案 1 :(得分:2)

我敢打赌hg会返回错误代码。也许您可以将hg import包装在一个shell脚本中,该脚本捕获返回的错误代码并在出现错误时执行您想要的操作?类似的东西:

#!/bin/sh
# run the script by typing `hgimp patch_name.patch`
# $1 below will contain patch_name.patch
hg import $1

# if the return code is not equal to 0, run vimdiff or whatever
if [ ! "$?" -eq '0' ]; then
    # run your diff/cleanup commands here
fi
相关问题