Patchwork [6,of,7,V2] cat: call the storage prefetch hook

login
register
mail settings
Submitter Matt Harbison
Date Feb. 6, 2018, 5:29 a.m.
Message ID <73ff18b27dd03449d996.1517894949@Envy>
Download mbox | patch
Permalink /patch/27348/
State Accepted
Headers show

Comments

Matt Harbison - Feb. 6, 2018, 5:29 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1517776009 18000
#      Sun Feb 04 15:26:49 2018 -0500
# Node ID 73ff18b27dd03449d99668148afc02894162a2ae
# Parent  4e8306a344c8660625a1a85e139fa4deded6b82c
cat: call the storage prefetch hook

It's not important to call in the case of a single file, but maybe it's better
to do so for consistency.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2188,12 +2188,16 @@ 
         mfnode = ctx.manifestnode()
         try:
             if mfnode and mfl[mfnode].find(file)[0]:
+                _prefetchfiles(repo, ctx, [file])
                 write(file)
                 return 0
         except KeyError:
             pass
 
-    for abs in ctx.walk(matcher):
+    files = [f for f in ctx.walk(matcher)]
+    _prefetchfiles(repo, ctx, files)
+
+    for abs in files:
         write(abs)
         err = 0
 
diff --git a/tests/test-lfs-test-server.t b/tests/test-lfs-test-server.t
--- a/tests/test-lfs-test-server.t
+++ b/tests/test-lfs-test-server.t
@@ -177,6 +177,26 @@ 
   ../archive/c
   ../archive/d
 
+Cat will prefetch blobs in a group
+
+  $ rm -rf .hg/store/lfs `hg config lfs.usercache`
+  $ hg cat -vr 1 a b c
+  lfs: need to transfer 3 objects (43 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 d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 (19 bytes)
+  lfs: adding d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 to the usercache
+  lfs: processed: d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998
+  lfs: found 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b in the local lfs store
+  THIS-IS-LFS
+  lfs: found 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b in the local lfs store
+  THIS-IS-LFS
+  lfs: found d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 in the local lfs store
+  ANOTHER-LARGE-FILE
+
 Revert will prefetch blobs in a group
 
   $ rm -rf .hg/store/lfs