diff --git a/mercurial/archival.py b/mercurial/archival.py --- a/mercurial/archival.py +++ b/mercurial/archival.py @@ -37,6 +37,10 @@ def tidyprefix(dest, kind, prefix): prefix = util.pconvert(lpfx) if not prefix.endswith('/'): prefix += '/' + # Drop the leading '.' path component if present, so Windows can read the + # zip files (issue4634) + if prefix.startswith('./'): + prefix = prefix[2:] if prefix.startswith('../') or os.path.isabs(lpfx) or '/../' in prefix: raise util.Abort(_('archive prefix contains illegal components')) return prefix diff --git a/tests/test-subrepo-deep-nested-change.t b/tests/test-subrepo-deep-nested-change.t --- a/tests/test-subrepo-deep-nested-change.t +++ b/tests/test-subrepo-deep-nested-change.t @@ -309,17 +309,17 @@ Exclude large files from main and sub-su Exclude normal files from main and sub-sub repo - $ hg --config extensions.largefiles= archive -S -X '**.txt' ../archive_lf.tgz + $ hg --config extensions.largefiles= archive -S -X '**.txt' -p '.' ../archive_lf.tgz $ tar -tzf ../archive_lf.tgz | sort - archive_lf/.hgsub - archive_lf/.hgsubstate - archive_lf/large.bin - archive_lf/main - archive_lf/sub1/.hgsub - archive_lf/sub1/.hgsubstate - archive_lf/sub1/sub1 - archive_lf/sub1/sub2/large.bin - archive_lf/sub1/sub2/sub2 + .hgsub + .hgsubstate + large.bin + main + sub1/.hgsub + sub1/.hgsubstate + sub1/sub1 + sub1/sub2/large.bin + sub1/sub2/sub2 Include normal files from within a largefiles subrepo diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t --- a/tests/test-subrepo-git.t +++ b/tests/test-subrepo-git.t @@ -325,13 +325,13 @@ archive subrepos ../archive_x/s ../archive_x/s/g - $ hg -R ../tc archive -S ../archive.tgz 2>/dev/null + $ hg -R ../tc archive -S ../archive.tgz --prefix '.' 2>/dev/null $ tar -tzf ../archive.tgz | sort - archive/.hg_archival.txt - archive/.hgsub - archive/.hgsubstate - archive/a - archive/s/g + .hg_archival.txt + .hgsub + .hgsubstate + a + s/g create nested repo diff --git a/tests/test-subrepo-recursion.t b/tests/test-subrepo-recursion.t --- a/tests/test-subrepo-recursion.t +++ b/tests/test-subrepo-recursion.t @@ -312,7 +312,7 @@ only show up in the test output, not in Test archiving to zip file (unzip output is unstable): - $ hg archive --subrepos ../archive.zip + $ hg archive --subrepos --prefix '.' ../archive.zip \r (no-eol) (esc) archiving [ ] 0/3\r (no-eol) (esc) archiving [ ] 0/3\r (no-eol) (esc) @@ -339,6 +339,20 @@ Test archiving to zip file (unzip output archiving (foo/bar) [================================>] 1/1\r (no-eol) (glob) (esc) archiving (foo/bar) [================================>] 1/1\r (no-eol) (glob) (esc) \r (no-eol) (esc) + $ unzip -l ../archive.zip + Archive: ../archive.zip + Length Date Time Name + --------- ---------- ----- ---- + 172 01-01-1980 00:00 .hg_archival.txt + 10 01-01-1980 00:00 .hgsub + 45 01-01-1980 00:00 .hgsubstate + 3 01-01-1980 00:00 x.txt + 10 01-01-1980 00:00 foo/.hgsub + 45 01-01-1980 00:00 foo/.hgsubstate + 9 01-01-1980 00:00 foo/y.txt + 9 01-01-1980 00:00 foo/bar/z.txt + --------- ------- + 303 8 files Test archiving a revision that references a subrepo that is not yet cloned: @@ -363,7 +377,7 @@ cloned: $ cd ../empty #if hardlink - $ hg archive --subrepos -r tip ../archive.tar.gz + $ hg archive --subrepos -r tip --prefix './' ../archive.tar.gz \r (no-eol) (esc) archiving [ ] 0/3\r (no-eol) (esc) archiving [ ] 0/3\r (no-eol) (esc) @@ -413,7 +427,7 @@ cloned: #else Note there's a slight output glitch on non-hardlink systems: the last "linking" progress topic never gets closed, leading to slight output corruption on that platform. - $ hg archive --subrepos -r tip ../archive.tar.gz + $ hg archive --subrepos -r tip --prefix './' ../archive.tar.gz \r (no-eol) (esc) archiving [ ] 0/3\r (no-eol) (esc) archiving [ ] 0/3\r (no-eol) (esc) @@ -437,14 +451,14 @@ Note there's a slight output glitch on n Archive + subrepos uses '/' for all component separators $ tar -tzf ../archive.tar.gz | sort - archive/.hg_archival.txt - archive/.hgsub - archive/.hgsubstate - archive/foo/.hgsub - archive/foo/.hgsubstate - archive/foo/bar/z.txt - archive/foo/y.txt - archive/x.txt + .hg_archival.txt + .hgsub + .hgsubstate + foo/.hgsub + foo/.hgsubstate + foo/bar/z.txt + foo/y.txt + x.txt The newly cloned subrepos contain no working copy: