Andrew G
Andrew G

Reputation: 827

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.

Upvotes: 8

Views: 4318

Answers (2)

Kurt McKee
Kurt McKee

Reputation: 1410

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

Upvotes: 2

John Weldon
John Weldon

Reputation: 40749

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.

Upvotes: 3

Related Questions