I have successfully imported patches without having conflicting changes. But when I try to import patch with conflicting changes it throws an error saying “Hunk #1 FAILED at 11.. “. There is no option to merge changes. Is there any other way to accomplish this?
I have successfully imported patches without having conflicting changes. But when I try to
Share
Manual resolution
The latest versions of TortoiseHg 2.1 have tools for helping you resolve rejected chunks from patches. When you apply a patch and it has rejections, for each file with rejections it asks if you want to resolve rejected chunks. If you click Yes, it shows you a screen with the content of the file (with successful chunks applied) as well as each chunk that was rejected, to allow you to manually do the changes a little easier and mark each as resolved.
Achieving 3-Way Merge
The way that I sometimes handle large rejections is to rebase the patch. In TortoiseHg 1.x I could select one node, right-click on another and actually rebase patches. In TortoiseHg 2.x they have not yet added that back in, but the workaround isn’t so bad. You can still rebase patches on the commandline using
hg rebase. In either case, you need themqandrebaseextensions enabled (and you probably already have the former enabled). This answer is not a place for teaching how to usemqorrebase(there are plenty of other answers and articles that do that), so I will be assuming some familiarity with them.In both, you will need to apply the patch to the revision on which it was based (or to one where it applies cleanly or close to clean).
Commandline:
Run
hg rebase -spatchRev-d tip. Along with whatever other switches you want on therebasecommand.This will bring up your 3-way merge tool to resolve conflicts, for each file.
Run
hg qrefreshto make sure the merge results are updated into the patch.TortoiseHg UI
I prefer the latter method for the more troublesome instances because it by default prevents Mercurial from automatically resolving conflicts. It allows me to choose the order in which I resolve files and how I resolve them, showing the status of my progress with each step.