# HG changeset patch # User Martin Geisler # Date 2011-10-17 14:45:19 # Node ID 4be845e3932cff65d62cd6b99ae40ba30e0f9f28 # Parent 42e71f5852eea5527e1d6aabe48ac7cb42a16366 subrepo: pull revisions on demand when archiving hg subrepos Before, running 'hg archive -S' could result in abort: unknown revision '65903cebad86f1a84bd4f1134f62fa7dcb7a1c98'! if a subrepo was missing completely or had missing changesets. Now, the missing changesets will be pulled or cloned as appropriate. This make Mercurial subrepos match Git subrepos which already took care to fetch any missing commits before starting the archive. diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -418,6 +418,7 @@ class hgsubrepo(abstractsubrepo): % (inst, subrelpath(self))) def archive(self, ui, archiver, prefix): + self._get(self._state + ('hg',)) abstractsubrepo.archive(self, ui, archiver, prefix) rev = self._state[1] 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 @@ -304,6 +304,47 @@ Test archiving to zip file (unzip output archiving (foo/bar) [================================>] 1/1 \r (esc) +Test archiving a revision that references a subrepo that is not yet +cloned: + + $ hg clone -U . ../empty + $ cd ../empty + $ hg archive --subrepos -r tip ../archive.tar.gz 2>&1 | $TESTDIR/filtercr.py + + archiving [ ] 0/3 + archiving [ ] 0/3 + archiving [=============> ] 1/3 + archiving [=============> ] 1/3 + archiving [===========================> ] 2/3 + archiving [===========================> ] 2/3 + archiving [==========================================>] 3/3 + archiving [==========================================>] 3/3 + + archiving (foo) [ ] 0/3 + archiving (foo) [ ] 0/3 + archiving (foo) [===========> ] 1/3 + archiving (foo) [===========> ] 1/3 + archiving (foo) [=======================> ] 2/3 + archiving (foo) [=======================> ] 2/3 + archiving (foo) [====================================>] 3/3 + archiving (foo) [====================================>] 3/3 + + archiving (foo/bar) [ ] 0/1 + archiving (foo/bar) [ ] 0/1 + archiving (foo/bar) [================================>] 1/1 + archiving (foo/bar) [================================>] 1/1 + + cloning subrepo foo from $TESTTMP/repo/foo + cloning subrepo foo/bar from $TESTTMP/repo/foo/bar + +The newly cloned subrepos contain no working copy: + + $ hg -R foo summary + parent: -1:000000000000 (no revision checked out) + branch: default + commit: (clean) + update: 4 new changesets (update) + Disable progress extension and cleanup: $ mv $HGRCPATH.no-progress $HGRCPATH