# HG changeset patch
# User Matt Harbison
# Date 1523751087 14400
# Sat Apr 14 20:11:27 2018 -0400
# Node ID 317c4321147ef610a2f229dd87953829d7eebf3d
# Parent c44d4efe94b05253d30bb507dd4cca70ad1d94f0
diff: invoke the file prefetch hook
By invoking it this deep within the command, we pick up both subrepo and hgweb
support, as well as --patch support for commands that implement logopts.
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2466,6 +2466,10 @@ def diffhunks(repo, node1=None, node2=No
# reported as copies. We want to show them in the diff as
additions.
del copy[dst]
+prefetchmatch = scmutil.matchfiles(repo,
+[f for f in modifiedset | addedset | removedset])
+scmutil.prefetchfiles(repo, [ctx1.rev(), ctx2.rev()], prefetchmatch)
+
def difffn(opts, losedata):
return trydiff(repo, revs, ctx1, ctx2, modified, added, removed,
copy, getfilectx, opts, losedata, prefix, relroot)
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
@@ -365,6 +365,71 @@ Export with selected files is used with
cleaning up temp directory
[1]
+Diff will prefetch files
+
+ $ rm -r $TESTTMP/bulkfetch/.hg/store/lfs
+ $ hg -R $TESTTMP/bulkfetch -v diff -r 2:tip
+ lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs
+ lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs
+ lfs: need to transfer 4 objects (92 bytes)
+ lfs: downloading
a82f1c5cea0d40e3bb3a849686bb4e6ae47ca27e614de55c1ed0325698ef68de (25 bytes)
+ lfs: processed:
a82f1c5cea0d40e3bb3a849686bb4e6ae47ca27e614de55c1ed0325698ef68de
+ lfs: downloading
bed80f00180ac404b843628ab56a1c1984d6145c391cd1628a7dd7d2598d71fc (23 bytes)
+ lfs: processed:
bed80f00180ac404b843628ab56a1c1984d6145c391cd1628a7dd7d2598d71fc
+ lfs: downloading
cf1b2787b74e66547d931b6ebe28ff63303e803cb2baa14a8f57c4383d875782 (20 bytes)
+ lfs: processed:
cf1b2787b74e66547d931b6ebe28ff63303e803cb2baa14a8f57c4383d875782
+ lfs: downloading
d96eda2c74b56e95cfb5ffb66b6503e198cc6fc4a09dc877de925feebc65786e (24 bytes)
+ lfs: processed:
d96eda2c74b56e95cfb5ffb66b6503e198cc6fc4a09dc877de925feebc65786e
+ lfs: found bed80f00180ac404b843628ab56a1c1984d6145c391cd1628a7dd7d2598d71fc
in the local lfs store
+ lfs: found a82f1c5cea0d40e3bb3a849686bb4e6ae47ca27e614de55c1ed0325698ef68de
in the local lfs store
+ lfs: found cf1b2787b74e66547d931b6ebe28ff63303e803cb2baa14a8f57c4383d875782
in the local lfs store
+ lfs: found d96eda2c74b56e95cfb5ffb66b6503e198cc6fc4a09dc877de925feebc65786e
in the local lfs store
+ diff -r 8374dc4052cb -r 9640b57e77b1 lfs.bin
+ --- a/lfs.binThu Jan 01 00:00:00 1970 +
+ +++ /dev/nullThu Jan 01 00:00:00 1970 +
+ @@ -1,1 +0,0 @@
+ -this is a big lfs file
+ diff -r 8374dc4052cb -r 9640b57e77b1 lfs2.txt
+ --- /dev/nullThu Jan 01 00:00:00 1970 +
+ +++ b/lfs2.txt Thu Jan 01 00:00:00 1970 +
+ @@ -0,0 +1,1 @@
+ +this is another lfs file
+ diff -r 8374dc4052cb -r 9640b57e77b1 lfspair1.bin
+ --- /dev/nullThu Jan 01 00:00:00 1970 +
+ +++ b/lfspair1.bin Thu Jan 01 00:00:00 1970 +
+ @@ -0,0 +1,1 @@
+ +this is an lfs file
+ diff -r 8374dc4052cb -r 9640b57e77b1 lfspair2.bin
+ --- /dev/nullThu Jan 01 00:00:00 1970 +
+ +++ b/lfspair2.bin Thu Jan 01 00:00:00 1970 +
+ @@ -0,0 +1,1 @@
+ +this is an lfs file too
+ diff -r 8374dc4052cb -r 9640b57e77b1 nonlfs.txt
+ --- a/nonlfs.txt Thu Jan 01 00:00:00 1970 +
+ +++ /dev/nullThu Jan 01 00:00:00 1970 +
+ @@ -1,1 +0,0 @@
+ -non-lfs
+ diff -r 8374dc4052cb -r 9640b57e77b1 nonlfs3.txt
+ --- /dev/nullThu Jan 01 00:00:00 1970 +
+ +++ b/nonlfs3.txtThu Jan 01 00:00:00 1970 +
+ @@ -0,0 +1,1 @@
+ +non-lfs
+
+Only the files required by diff are prefetched
+
+ $ rm -r $TESTTMP/bulkfetch/.hg/store/lfs
+ $ hg -R $TESTTMP/bulkfetch -v diff -r 2:tip $TESTTMP/bulkfetch/lfspair2.bin
+ lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs
+ lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs
+ lfs: downloading
d96eda2c74b56e95cfb5ffb66b6503e198cc6fc4a09dc877de925feebc65786e (24 bytes)
+ lfs: processed:
d96eda2c74b56e95cfb5ffb66b6503e198cc6fc4a09dc877de925feebc65786e
+ lfs: found d96eda2c74b56e95cfb5ffb66b6503e198cc6fc4a09dc877de925feebc65786e
in the local lfs store
+ diff -r 8374dc4052cb -r 9640b57e77b1 lfspair2.bin
+ --- /dev/nullThu Jan 01 00:00:00 1970 +
+ +++ b/lfspair2.bin Thu Jan 01 00:00:00 1970 +
+ @@ -0,0 +1,1 @@
+ +this is an lfs file too
+
#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