archive: call the storage prefetch hook
authorMatt Harbison <matt_harbison@yahoo.com>
Sun, 04 Feb 2018 14:31:32 -0500
changeset 35925 533f04d4cb6d
parent 35924 d857cad588e4
child 35926 264b90a060b7
archive: call the storage prefetch hook
mercurial/archival.py
mercurial/subrepo.py
tests/test-lfs-test-server.t
--- a/mercurial/archival.py	Sun Feb 04 00:33:28 2018 -0500
+++ b/mercurial/archival.py	Sun Feb 04 14:31:32 2018 -0500
@@ -18,6 +18,7 @@
 from .i18n import _
 
 from . import (
+    cmdutil,
     error,
     formatter,
     match as matchmod,
@@ -337,6 +338,7 @@
     total = len(files)
     if total:
         files.sort()
+        cmdutil._prefetchfiles(repo, ctx, files)
         repo.ui.progress(_('archiving'), 0, unit=_('files'), total=total)
         for i, f in enumerate(files):
             ff = ctx.flags(f)
--- a/mercurial/subrepo.py	Sun Feb 04 00:33:28 2018 -0500
+++ b/mercurial/subrepo.py	Sun Feb 04 14:31:32 2018 -0500
@@ -919,9 +919,13 @@
     @annotatesubrepoerror
     def archive(self, archiver, prefix, match=None, decode=True):
         self._get(self._state + ('hg',))
-        total = abstractsubrepo.archive(self, archiver, prefix, match)
+        files = self.files()
+        if match:
+            files = [f for f in files if match(f)]
         rev = self._state[1]
         ctx = self._repo[rev]
+        cmdutil._prefetchfiles(self._repo, ctx, files)
+        total = abstractsubrepo.archive(self, archiver, prefix, match)
         for subpath in ctx.substate:
             s = subrepo(ctx, subpath, True)
             submatch = matchmod.subdirmatcher(subpath, match)
--- a/tests/test-lfs-test-server.t	Sun Feb 04 00:33:28 2018 -0500
+++ b/tests/test-lfs-test-server.t	Sun Feb 04 14:31:32 2018 -0500
@@ -149,6 +149,34 @@
   (run hg verify)
   [255]
 
+Archive will prefetch blobs in a group
+
+  $ rm -rf .hg/store/lfs `hg config lfs.usercache`
+  $ hg archive -vr 1 ../archive
+  lfs: need to transfer 4 objects (63 bytes)
+  lfs: downloading 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b (12 bytes)
+  lfs: adding 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b to the usercache
+  lfs: processed: 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b
+  lfs: downloading 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b (12 bytes)
+  lfs: processed: 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b
+  lfs: downloading 37a65ab78d5ecda767e8622c248b5dbff1e68b1678ab0e730d5eb8601ec8ad19 (20 bytes)
+  lfs: adding 37a65ab78d5ecda767e8622c248b5dbff1e68b1678ab0e730d5eb8601ec8ad19 to the usercache
+  lfs: processed: 37a65ab78d5ecda767e8622c248b5dbff1e68b1678ab0e730d5eb8601ec8ad19
+  lfs: downloading d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 (19 bytes)
+  lfs: adding d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 to the usercache
+  lfs: processed: d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998
+  lfs: found 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b in the local lfs store
+  lfs: found 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b in the local lfs store
+  lfs: found d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 in the local lfs store
+  lfs: found 37a65ab78d5ecda767e8622c248b5dbff1e68b1678ab0e730d5eb8601ec8ad19 in the local lfs store
+  $ find ../archive | sort
+  ../archive
+  ../archive/.hg_archival.txt
+  ../archive/a
+  ../archive/b
+  ../archive/c
+  ../archive/d
+
 Revert will prefetch blobs in a group
 
   $ rm -rf .hg/store/lfs