diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1039,9 +1039,12 @@ def applydiff(ui, fp, changed, strip=1, continue elif state == 'git': gitpatches = values + cwd = os.getcwd() for gp in gitpatches: if gp.op in ('COPY', 'RENAME'): - copyfile(gp.oldpath, gp.path) + src, dst = [util.canonpath(cwd, cwd, x) + for x in [gp.oldpath, gp.path]] + copyfile(src, dst) changed[gp.path] = (gp.op, gp) else: raise util.Abort(_('unsupported parser state: %s') % state) diff --git a/tests/test-import b/tests/test-import --- a/tests/test-import +++ b/tests/test-import @@ -261,3 +261,15 @@ EOF hg status cat a cd .. + +echo % 'test paths outside repo root' +mkdir outside +touch outside/foo +hg init inside +cd inside +hg import - <