changeset 15286:4be845e3932c stable

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.
author Martin Geisler <mg@aragost.com>
date Mon, 17 Oct 2011 16:45:19 +0200
parents 42e71f5852ee
children b3e19c355ca7
files mercurial/subrepo.py tests/test-subrepo-recursion.t
diffstat 2 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Mon Oct 17 14:27:34 2011 +0200
+++ b/mercurial/subrepo.py	Mon Oct 17 16:45:19 2011 +0200
@@ -418,6 +418,7 @@
                                % (inst, subrelpath(self)))
 
     def archive(self, ui, archiver, prefix):
+        self._get(self._state + ('hg',))
         abstractsubrepo.archive(self, ui, archiver, prefix)
 
         rev = self._state[1]
--- a/tests/test-subrepo-recursion.t	Mon Oct 17 14:27:34 2011 +0200
+++ b/tests/test-subrepo-recursion.t	Mon Oct 17 16:45:19 2011 +0200
@@ -304,6 +304,47 @@
   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