Patchwork [4,of,7,V2] lfs: prefetch lfs blobs during revert

login
register
mail settings
Submitter Matt Harbison
Date Feb. 6, 2018, 5:29 a.m.
Message ID <d5eedbdb4116e4899152.1517894947@Envy>
Download mbox | patch
Permalink /patch/27347/
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 1517722408 18000
#      Sun Feb 04 00:33:28 2018 -0500
# Node ID d5eedbdb4116e489915228341f9bde22224922bd
# Parent  ab23d9644edaf62b2c3927b735d2170fc76ca711
lfs: prefetch lfs blobs during revert

The revert command oddly prints out what it will do before requesting the files
to be prefetched.  But the 'need to transfer' line indicates the blobs are being
grouped.

Patch

diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -333,6 +333,7 @@ 
     wrapfunction(hg, 'postshare', wrapper.hgpostshare)
 
     wrapfunction(merge, 'applyupdates', wrapper.mergemodapplyupdates)
+    wrapfunction(cmdutil, '_prefetchfiles', wrapper.cmdutilprefetchfiles)
 
     # Make bundle choose changegroup3 instead of changegroup2. This affects
     # "hg bundle" command. Note: it does not cover all bundle formats like
diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py
--- a/hgext/lfs/wrapper.py
+++ b/hgext/lfs/wrapper.py
@@ -266,6 +266,12 @@ 
     if pointers:
         repo.svfs.lfsremoteblobstore.readbatch(pointers, localstore)
 
+def cmdutilprefetchfiles(orig, repo, ctx, files):
+    """Prefetch the indicated files before they are accessed by a command."""
+    orig(repo, ctx, files)
+
+    _prefetchfiles(repo, ctx, files)
+
 def mergemodapplyupdates(orig, repo, actions, wctx, mctx, overwrite,
                          labels=None):
     """Ensure that the required LFS blobs are present before applying updates,
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
@@ -149,6 +149,33 @@ 
   (run hg verify)
   [255]
 
+Revert will prefetch blobs in a group
+
+  $ rm -rf .hg/store/lfs
+  $ rm -rf `hg config lfs.usercache`
+  $ rm *
+  $ hg revert --all -r 1 -v
+  adding a
+  reverting b
+  reverting c
+  reverting d
+  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 d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 in the local lfs store
+  lfs: found 37a65ab78d5ecda767e8622c248b5dbff1e68b1678ab0e730d5eb8601ec8ad19 in the local lfs store
+  lfs: found 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b in the local lfs store
+
 Check error message when the remote missed a blob:
 
   $ echo FFFFF > b