diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -467,7 +467,7 @@ class hgsubrepo(abstractsubrepo): self._repo.ui.status(_('cloning subrepo %s from %s\n') % (subrelpath(self), srcurl)) parentrepo = self._repo._subparent - shutil.rmtree(self._repo.root) + shutil.rmtree(self._repo.path) other, self._repo = hg.clone(self._repo._subparent.ui, {}, other, self._repo.root, update=False) self._initrepo(parentrepo, source, create=True) 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 @@ -349,6 +349,18 @@ Disable progress extension and cleanup: $ mv $HGRCPATH.no-progress $HGRCPATH +Test archiving when there is a directory in the way for a subrepo +created by archive: + + $ hg clone -U . ../almost-empty + $ cd ../almost-empty + $ mkdir foo + $ echo f > foo/f + $ hg archive --subrepos -r tip archive + cloning subrepo foo from $TESTTMP/empty/foo + abort: destination '$TESTTMP/almost-empty/foo' is not empty + [255] + Clone and test outgoing: $ cd ..