tags:

views:

139

answers:

2

I have a patch, made with hg export 42 in another repository, that modifies the files

asd/fgh/foo/bar.c
asd/fgh/foo/fish.h
boo/hoo.txt

I need to import this patch to a repository that has the structure like:

src/foo/bar.c
src/foo/fish.h
boo/hoo.txt

Is there any command that can accomplish this - I can re-run the hg export on the old repo if needed, and am willing to ignore the files that have same path (e.g. boo/hoo.txt)

I thought originally that hg import -p3 patch.diff in repository/src would have done this, but apparently it still wants to create the asd/fgh/ hierarchy in the top level (and place .rej files there)

A: 

One option is to go into the patch file and just change the names. A few search and replaces and you're probably good to go.

The only mercurial command I know that accepts a filename translation map is the 'convert' command, so there's probably a solution to be found by running the old repo through something like hg convert --filemap thefilemap exportingrepo newexportingrepo, where thefilemap has in it:

rename asd/fgh src

then export it from newexportingrepo and import into the receiving repo.

Me, I'd probably hand edit the patch. :)

Ry4an
Ended up hand editing the patch myself, too
Kimvais
A: 

you could always do it in two changes. rename the directories then apply the patch.

jk