# HG changeset patch # User Brendan Cully # Date 1214428400 25200 # Node ID 87c704ac92d42f7e16b24593f56a0d33ffc8fd20 # Parent 55c71226eceb05379f60a6b51830151198a83c59 Check that git patches only touch files under root diff -r 55c71226eceb -r 87c704ac92d4 mercurial/patch.py --- a/mercurial/patch.py Thu Jun 26 18:44:54 2008 -0500 +++ b/mercurial/patch.py Wed Jun 25 14:13:20 2008 -0700 @@ -1039,9 +1039,12 @@ 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 -r 55c71226eceb -r 87c704ac92d4 tests/test-import --- a/tests/test-import Thu Jun 26 18:44:54 2008 -0500 +++ b/tests/test-import Wed Jun 25 14:13:20 2008 -0700 @@ -261,3 +261,15 @@ hg status cat a cd .. + +echo % 'test paths outside repo root' +mkdir outside +touch outside/foo +hg init inside +cd inside +hg import - <