wikier
wikier

Reputation: 2566

How to generate a clean patch from Mercurial?

The diff command, even using git option, includes path prefixes commonly used on DCS:

--- a/file.ext
+++ b/file.ext

So applying such patches you should need to using -p1 instead of -p0.

Is there any way to generate clean patched from Mercurial?

Upvotes: 0

Views: 142

Answers (2)

krtek
krtek

Reputation: 26597

You could adapt the see script given in this answer : transforming patch strip level to remove the first directory instead of adding it.

Something like this should work (untested) :

sed \
    -e 's!^--- a/!--- !' \
    -e 's!^+++ b/!+++ !' \
    < p1.patch \
    > p0.patch

Assuming your "p1 patch" is in a file named p1.patch, the output will be in p0.patch

Upvotes: 0

Ry4an Brase
Ry4an Brase

Reputation: 78330

Mercurial won't emit -p0 patches. As @Ringdig points out, they're very seldom what you want.

Upvotes: 1

Related Questions