Mercurial > hg
comparison tests/test-lfs-test-server.t @ 35098:66c5a8cf2868
lfs: import the Facebook git-lfs client extension
The purpose of this is the same as the built-in largefiles extension- to handle
huge files outside of the normal storage system, generally to keep the amount of
data cloned to a lower amount. There are several benefits of implementing the
git-lfs protocol, instead of using the largefiles extension:
- Bitbucket and Github support (and probably wider support in 3rd party
hosting sites in general). [1][2]
- The number of hg internals monkey patched are several orders of magnitude
lower, so it will be easier to reason about and maintain. Future commands
will likely just work, without requiring various wrappers.
- The "standin" files are only written to the filelog, not the disk. That
should avoid weird edge cases where the largefile and standin files get out
of sync. [3] It also avoids the occasional printing of the "hidden" standin
file in various messages.
- Filesets like size() will work, even if the file isn't present. (It always
says 41 bytes for largefiles, whether present or not.)
The only place that I see where largefiles comes out on top is that it works
with `hg serve` for simple sharing, without external infrastructure. Getting
lfs-test-server working was a hassle, and took awhile to figure out. Maybe we
can do something to make it work in the future.
Long term, I expect that this will be highly preferred over largefiles. But if
we are to recommend this to largefile users, there are some UI issues to
bikeshed. Until they are resolved, I've marked this experimental, and am not
putting a pointer to this in the largefiles help. The (non exhaustive) list of
issues I've seen so far are:
- It isn't sufficient to just enable the largefiles extension- you have to
explicitly add a file with --large before it will pay attention to the
configured sizes and patterns on future adds. The justification being that
once you use it, you're stuck with it. I've seen people confused by this,
and haven't liked it myself. But it's also saved me a few times. Should we
do something like have a specific enabling config setting that must be set
in the local repo config, so that enabling this extension in the user or
system hgrc doesn't silently start storing lfs files?
- The largefiles extension adds a repo requirement when the first largefile is
committed, so that the extension must always be enabled in the future. This
extension is not doing that, and since I only enabled it locally to avoid
infecting other repos, I got a cryptic error about missing flag processors
when I cloned. Is there no repo requirement due to shallow/narrow clone
considerations (or other future advanced things)?
- In the (small amount of) reading I've done about the git implementation, it
seems that the files and sizes are stored in a tracked .gitattributes file.
I think a tracked file for this would be extremely useful for consistency
across developers, but this kind of touches on the tracked hgrc file
proposal a few months back.
- The git client can specify file patterns, not just sizes.
- The largefiles extension has a cache directory in the local repo, but also a
system wide one. We should probably implement a system wide cache too, so
that multiple clones don't have to refetch the files from the server.
- Jun mentioned other missing features, like SSH authentication, gc, etc.
The code corresponds to c0492b73c7ef in hg-experimental. [4] The only tweaks
are to load the extension in the tests with 'lfs=' instead of
'lfs=$TESTDIR/../hgext3rd/lfs', change the import in the *.py test to hgext
(from hgext3rd), add the 'testedwith' declaration, and mark it experimental for
now. The infinite-push, p4fastimport, and remotefilelog tests were left behind.
The devel-warnings for unregistered config options are not corrected yet, nor
are the import check warnings.
[1] https://www.mercurial-scm.org/pipermail/mercurial/2017-November/050699.html
[2] https://bitbucket.org/site/master/issues/3843/largefiles-support-bb-3903
[3] https://bz.mercurial-scm.org/show_bug.cgi?id=5738
[4] https://bitbucket.org/facebook/hg-experimental
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 14 Nov 2017 00:06:23 -0500 |
parents | |
children | a2e927ded455 |
comparison
equal
deleted
inserted
replaced
35097:fc0f3ed071fc | 35098:66c5a8cf2868 |
---|---|
1 Require lfs-test-server (https://github.com/git-lfs/lfs-test-server) | |
2 | |
3 $ hash lfs-test-server || { echo 'skipped: missing lfs-test-server'; exit 80; } | |
4 | |
5 $ LFS_LISTEN="tcp://:$HGPORT" | |
6 $ LFS_HOST="localhost:$HGPORT" | |
7 $ LFS_PUBLIC=1 | |
8 $ export LFS_LISTEN LFS_HOST LFS_PUBLIC | |
9 $ lfs-test-server &> lfs-server.log & | |
10 $ echo $! >> $DAEMON_PIDS | |
11 | |
12 $ cat >> $HGRCPATH <<EOF | |
13 > [extensions] | |
14 > lfs= | |
15 > [lfs] | |
16 > url=http://foo:bar@$LFS_HOST/ | |
17 > threshold=1 | |
18 > EOF | |
19 | |
20 $ hg init repo1 | |
21 $ cd repo1 | |
22 $ echo THIS-IS-LFS > a | |
23 $ hg commit -m a -A a | |
24 | |
25 $ hg init ../repo2 | |
26 $ hg push ../repo2 -v | |
27 pushing to ../repo2 | |
28 searching for changes | |
29 lfs: uploading 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b (12 bytes) | |
30 1 changesets found | |
31 uncompressed size of bundle content: | |
32 * (changelog) (glob) | |
33 * (manifests) (glob) | |
34 * a (glob) | |
35 adding changesets | |
36 adding manifests | |
37 adding file changes | |
38 added 1 changesets with 1 changes to 1 files | |
39 | |
40 $ cd ../repo2 | |
41 $ hg update tip -v | |
42 resolving manifests | |
43 getting a | |
44 lfs: downloading 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b (12 bytes) | |
45 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
46 | |
47 When the server has some blobs already | |
48 | |
49 $ hg mv a b | |
50 $ echo ANOTHER-LARGE-FILE > c | |
51 $ echo ANOTHER-LARGE-FILE2 > d | |
52 $ hg commit -m b-and-c -A b c d | |
53 $ hg push ../repo1 -v | grep -v '^ ' | |
54 pushing to ../repo1 | |
55 searching for changes | |
56 lfs: need to transfer 2 objects (39 bytes) | |
57 lfs: uploading 37a65ab78d5ecda767e8622c248b5dbff1e68b1678ab0e730d5eb8601ec8ad19 (20 bytes) | |
58 lfs: uploading d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 (19 bytes) | |
59 1 changesets found | |
60 uncompressed size of bundle content: | |
61 adding changesets | |
62 adding manifests | |
63 adding file changes | |
64 added 1 changesets with 3 changes to 3 files | |
65 | |
66 $ hg --repo ../repo1 update tip -v | |
67 resolving manifests | |
68 getting b | |
69 getting c | |
70 lfs: downloading d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 (19 bytes) | |
71 getting d | |
72 lfs: downloading 37a65ab78d5ecda767e8622c248b5dbff1e68b1678ab0e730d5eb8601ec8ad19 (20 bytes) | |
73 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
74 | |
75 Check error message when the remote missed a blob: | |
76 | |
77 $ echo FFFFF > b | |
78 $ hg commit -m b -A b | |
79 $ echo FFFFF >> b | |
80 $ hg commit -m b b | |
81 $ rm -rf .hg/store/lfs | |
82 $ hg update -C '.^' | |
83 abort: LFS server claims required objects do not exist: | |
84 8e6ea5f6c066b44a0efa43bcce86aea73f17e6e23f0663df0251e7524e140a13! | |
85 [255] | |
86 | |
87 Check error message when object does not exist: | |
88 | |
89 $ hg init test && cd test | |
90 $ echo "[extensions]" >> .hg/hgrc | |
91 $ echo "lfs=" >> .hg/hgrc | |
92 $ echo "[lfs]" >> .hg/hgrc | |
93 $ echo "threshold=1" >> .hg/hgrc | |
94 $ echo a > a | |
95 $ hg add a | |
96 $ hg commit -m 'test' | |
97 $ echo aaaaa > a | |
98 $ hg commit -m 'largefile' | |
99 $ hg debugdata .hg/store/data/a.i 1 # verify this is no the file content but includes "oid", the LFS "pointer". | |
100 version https://git-lfs.github.com/spec/v1 | |
101 oid sha256:bdc26931acfb734b142a8d675f205becf27560dc461f501822de13274fe6fc8a | |
102 size 6 | |
103 x-is-binary 0 | |
104 $ cd .. | |
105 $ hg --config 'lfs.url=https://dewey-lfs.vip.facebook.com/lfs' clone test test2 | |
106 updating to branch default | |
107 abort: LFS server error. Remote object for file data/a.i not found:(.*)! (re) | |
108 [255] |