Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to apply patch in mercurial and show diff tool if failed apply

I want apply patch in Mercurial:

hg import patch_name.patch

But if I get the error abort: patch failed to apply, Mercurial creates *.rej files.

Is there a way show kdiff or vim-diif to correcting conflict.

like image 457
Andrew G Avatar asked Nov 04 '11 07:11

Andrew G


2 Answers

There isn't a way to do this. The recommended approach is to open the file and the .rej file and manually merge in the rejected hunks.

like image 170
John Weldon Avatar answered Sep 25 '22 07:09

John Weldon


I would bet that hg returns an error code. Perhaps you can wrap hg import in a shell script that catches the error code returned and does what you want if there was an error? Something like:

#!/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
like image 36
Kurt McKee Avatar answered Sep 25 '22 07:09

Kurt McKee