# HG changeset patch
# User Matt Harbison <matt_harbi...@yahoo.com>
# Date 1523756443 14400
#      Sat Apr 14 21:40:43 2018 -0400
# Node ID a3702d55eb1ca64fc220827482e9d3a17cbfbb57
# Parent  3b0c3d4939b56ca038dbbba17da424699a6b339d
grep: invoke the file prefetch hook

Because of the way `grep` works, I don't see an easy way to prefetch everything,
so this prefetches per revision as it walks.  The message between the file/line
number and the matching line is a --verbose output.  Since I don't expect this
to be used much with lfs content, I'm not going to worry about it.

I have no idea why the second test without an explicit file doesn't find the
match.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2553,6 +2553,8 @@ def grep(ui, repo, pattern, *pats, **opt
         matches.setdefault(rev, {})
         matches.setdefault(parent, {})
         files = revfiles.setdefault(rev, [])
+        scmutil.fileprefetchhooks(ctx.repo(), [ctx], fns)
+
         for fn in fns:
             flog = getfile(fn)
             try:
diff --git a/tests/test-lfs-serve.t b/tests/test-lfs-serve.t
--- a/tests/test-lfs-serve.t
+++ b/tests/test-lfs-serve.t
@@ -430,6 +430,34 @@ Only the files required by diff are pref
   @@ -0,0 +1,1 @@
   +this is an lfs file too
 
+Grep will prefetch files, as needed.
+
+  $ rm -r $TESTTMP/bulkfetch/.hg/store/lfs
+  $ hg -R $TESTTMP/bulkfetch grep -v lfs $TESTTMP/bulkfetch/lfs2.txt
+  lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs
+  lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs
+  lfs: downloading 
a82f1c5cea0d40e3bb3a849686bb4e6ae47ca27e614de55c1ed0325698ef68de (25 bytes)
+  lfs: processed: 
a82f1c5cea0d40e3bb3a849686bb4e6ae47ca27e614de55c1ed0325698ef68de
+  lfs: found a82f1c5cea0d40e3bb3a849686bb4e6ae47ca27e614de55c1ed0325698ef68de 
in the local lfs store
+  lfs2.txt:5:lfs: found 
a82f1c5cea0d40e3bb3a849686bb4e6ae47ca27e614de55c1ed0325698ef68de in the local 
lfs store
+  this is another lfs file
+  $ rm -r $TESTTMP/bulkfetch/.hg/store/lfs
+  $ hg -R $TESTTMP/bulkfetch grep -v lfs
+  lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs
+  lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs
+  lfs: downloading 
bed80f00180ac404b843628ab56a1c1984d6145c391cd1628a7dd7d2598d71fc (23 bytes)
+  lfs: processed: 
bed80f00180ac404b843628ab56a1c1984d6145c391cd1628a7dd7d2598d71fc
+  lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs
+  lfs: downloading 
a82f1c5cea0d40e3bb3a849686bb4e6ae47ca27e614de55c1ed0325698ef68de (25 bytes)
+  lfs: processed: 
a82f1c5cea0d40e3bb3a849686bb4e6ae47ca27e614de55c1ed0325698ef68de
+  lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs
+  lfs: need to transfer 2 objects (44 bytes)
+  lfs: downloading 
cf1b2787b74e66547d931b6ebe28ff63303e803cb2baa14a8f57c4383d875782 (20 bytes)
+  lfs: processed: 
cf1b2787b74e66547d931b6ebe28ff63303e803cb2baa14a8f57c4383d875782
+  lfs: downloading 
d96eda2c74b56e95cfb5ffb66b6503e198cc6fc4a09dc877de925feebc65786e (24 bytes)
+  lfs: processed: 
d96eda2c74b56e95cfb5ffb66b6503e198cc6fc4a09dc877de925feebc65786e
+  [1]
+
 #endif
 
   $ $PYTHON $TESTDIR/killdaemons.py $DAEMON_PIDS
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to