# HG changeset patch # User Matt Harbison # Date 2015-05-05 02:33:29 # Node ID 41cd8171e58f991373dcd0b4897dc1e5978d42dd # Parent b5eb01500696f941efe357817f05de5136b4cc80 archive: always use portable path component separators with subrepos The previous behavior when archiving a subrepo 's' on Windows was to internally name the file under it 's\file', due to the use of vfs.reljoin(). When printing the file list from the archive on Windows or Linux, the file was named 's\\file'. The archive extracted OK on Windows, but if the archive was brought to a Linux system, it created a file named 's\file' instead of a directory 's' containing 'file'. *.zip format achives seemed not to have the problem, but this was definitely an issue with *.tgz archives. Largefiles actually got this right, but a test is added to keep this from regressing. The subrepo-deep-nested-change.t test was repurposed to archive to a file, since there are several subsequent tests that archive to a directory. The output change is losing the filesystem prefix '../archive_lf' and not listing the directories 'sub1' and 'sub1/sub2'. diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -517,7 +517,7 @@ class abstractsubrepo(object): flags = self.fileflags(name) mode = 'x' in flags and 0755 or 0644 symlink = 'l' in flags - archiver.addfile(self.wvfs.reljoin(prefix, self._path, name), + archiver.addfile(prefix + self._path + '/' + name, mode, symlink, self.filedata(name)) self.ui.progress(_('archiving (%s)') % relpath, i + 1, unit=_('files'), total=total) @@ -731,8 +731,7 @@ class hgsubrepo(abstractsubrepo): for subpath in ctx.substate: s = subrepo(ctx, subpath) submatch = matchmod.narrowmatcher(subpath, match) - total += s.archive( - archiver, self.wvfs.reljoin(prefix, self._path), submatch) + total += s.archive(archiver, prefix + self._path + '/', submatch) return total @annotatesubrepoerror @@ -1675,7 +1674,7 @@ class gitsubrepo(abstractsubrepo): data = info.linkname else: data = tar.extractfile(info).read() - archiver.addfile(self.wvfs.reljoin(prefix, self._path, info.name), + archiver.addfile(prefix + self._path + '/' + info.name, info.mode, info.issym(), data) total += 1 self.ui.progress(_('archiving (%s)') % relpath, i + 1, 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,21 +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 - $ find ../archive_lf | sort - ../archive_lf - ../archive_lf/.hgsub - ../archive_lf/.hgsubstate - ../archive_lf/large.bin - ../archive_lf/main - ../archive_lf/sub1 - ../archive_lf/sub1/.hgsub - ../archive_lf/sub1/.hgsubstate - ../archive_lf/sub1/sub1 - ../archive_lf/sub1/sub2 - ../archive_lf/sub1/sub2/large.bin - ../archive_lf/sub1/sub2/sub2 - $ rm -rf ../archive_lf + $ hg --config extensions.largefiles= archive -S -X '**.txt' ../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 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,6 +325,14 @@ archive subrepos ../archive_x/s ../archive_x/s/g + $ hg -R ../tc archive -S ../archive.tgz 2>/dev/null + $ tar -tzf ../archive.tgz | sort + archive/.hg_archival.txt + archive/.hgsub + archive/.hgsubstate + archive/a + archive/s/g + create nested repo $ cd .. 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 @@ -434,6 +434,18 @@ Note there's a slight output glitch on n cloning subrepo foo/bar from $TESTTMP/repo/foo/bar (glob) #endif +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 + The newly cloned subrepos contain no working copy: $ hg -R foo summary