views:

138

answers:

2

Hi,

I'm using Mercurial repository and I have a patch in 'git' format and I wanted to know how I can apply that patch to my current repository which is Local.

Thanks

A: 

Try hg import --no-commit, Mozilla has a rather useful FAQ regarding trading patches between Git and Mercurial.

Depending on your platform, you can also just use patch, e.g. patch -p1 < some_patch_from_git.patch. That may actually be better as you'll see any fuzz and not have to deal with trusting the author just for one patch.

Edit

If your patch does not go in cleanly, none of the above methods are going to work. Your code base is not what the patch expects if hunks fail to apply. Look at the rejects and see what the patch expected your code to be at any given line, then rebase accordingly.

Tim Post
Does not work Triedit
Abid
I think `hg import`ing a patch is better, as it will preserve the original committer’s name and timestamp.
Laurens Holst
+1  A: 

hg import <patchfile(s)> should be able to handle git-style patches.

Use hg import --no-commit <patchfile(s)> if you don't want it to automatically commit the changes after each patch is imported.

Mozilla's FAQ mentions this: https://developer.mozilla.org/en/Mercurial_FAQ#How_can_I_diff_and_patch_files.3f

Amber
I tried but i get an error saying Not Trusting File
Abid
It says from untrusted user, weird
Abid
You sure it's not talking about untrusted hooks? That's the only trust model mercurial has built-into it, and it won't prevent the applying of patches.
Ry4an
I am fairly new to this but here is the error message patching file plugins/supported/text_editor/commands/editing.jsHunk #1 FAILED at 1291 out of 1 hunks FAILED -- saving rejects to file plugins/supported/text_editor/commands/editing.js.rejabort: patch failed to apply
Abid