Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get 'hg import' to use internal:merge

Right now when I hg import a patch, and it fails to apply cleanly, hg partially applies the patch (the hunks that could apply cleanly) and saves the rejected hunks to a .rej file.

I find this really annoying to work with. Is there a way to get hg to use internal:merge instead when this happens?

like image 697
HighCommander4 Avatar asked Jan 21 '14 16:01

HighCommander4


1 Answers

Obviosuly the import command does not have such an option and it seems to ignore any other merge tool configurations. I can think of 2 work-arounds:

  1. Use hg import --exact and then merge the import commit with your main head. This only works for patches created with the hg export command, i.e. patches with revision information. Then you can make a regular merge of your main head and the new head created by the import.

    $ hg import --exact foo.patch
    $ hg merge
    ... fix conflicts if needed ...
    $ hg commit -m 'apply patch foo'
    
  2. Use good old patch command:

    $ patch -p1 --merge < foo.patch`
    ... fix conflicts if needed ...
    $ hg commit -m 'apply patch foo'
    

    This creates in-file markers similar to internal:merge.

If these multiple-step solutions are no options for you, think about requesting a feature to add a --merge option to the import command. Alternatively you might glue these commands together in a script so you have your own one-shot import command.

like image 113
Oben Sonne Avatar answered Oct 20 '22 00:10

Oben Sonne