Debian Codegraph @

tests/test-lfs-largefiles.t

raw
1 #require no-chg
2
3 This tests the interaction between the largefiles and lfs extensions, and
4 conversion from largefiles -> lfs.
5
6 $ cat >> $HGRCPATH << EOF
7 > [extensions]
8 > largefiles =
9 >
10 > [lfs]
11 > # standin files are 41 bytes. Stay bigger for clarity.
12 > threshold = 42
13 > EOF
14
15 Setup a repo with a normal file and a largefile, above and below the lfs
16 threshold to test lfconvert. *.txt start life as a normal file; *.bin start as
17 an lfs/largefile.
18
19 $ hg init largefiles
20 $ cd largefiles
21 $ echo 'normal' > normal.txt
22 $ echo 'normal above lfs threshold 0000000000000000000000000' > lfs.txt
23 $ hg ci -Am 'normal.txt'
24 adding lfs.txt
25 adding normal.txt
26 $ echo 'largefile' > large.bin
27 $ echo 'largefile above lfs threshold 0000000000000000000000' > lfs.bin
28 $ hg add --large large.bin lfs.bin
29 $ hg ci -m 'add largefiles'
30
31 $ cat >> $HGRCPATH << EOF
32 > [extensions]
33 > lfs =
34 > EOF
35
36 Add an lfs file and normal file that collide with files on the other branch.
37 large.bin is added as a normal file, and is named as such only to clash with the
38 largefile on the other branch.
39
40 $ hg up -q '.^'
41 $ echo 'below lfs threshold' > large.bin
42 $ echo 'lfs above the lfs threshold for length 0000000000000' > lfs.bin
43 $ hg ci -Am 'add with lfs extension'
44 adding large.bin
45 adding lfs.bin
46 created new head
47
48 $ hg log -G
49 @ changeset: 2:e989d0fa3764
50 | tag: tip
51 | parent: 0:29361292f54d
52 | user: test
53 | date: Thu Jan 01 00:00:00 1970 +0000
54 | summary: add with lfs extension
55 |
56 | o changeset: 1:6513aaab9ca0
57 |/ user: test
58 | date: Thu Jan 01 00:00:00 1970 +0000
59 | summary: add largefiles
60 |
61 o changeset: 0:29361292f54d
62 user: test
63 date: Thu Jan 01 00:00:00 1970 +0000
64 summary: normal.txt
65
66 --------------------------------------------------------------------------------
67 Merge largefiles into lfs branch
68
69 The largefiles extension will prompt to use the normal or largefile when merged
70 into the lfs files. `hg manifest` will show standins if present. They aren't,
71 because largefiles merge doesn't merge content. If it did, selecting (n)ormal
72 would convert to lfs on commit, if appropriate.
73
74 BUG: Largefiles isn't running the merge tool, like when two lfs files are
75 merged. This is probably by design, but it should probably at least prompt if
76 content should be taken from (l)ocal or (o)ther as well.
77
78 $ hg --config ui.interactive=True merge 6513aaab9ca0 <<EOF
79 > n
80 > n
81 > EOF
82 remote turned local normal file large.bin into a largefile
83 use (l)argefile or keep (n)ormal file? n
84 remote turned local normal file lfs.bin into a largefile
85 use (l)argefile or keep (n)ormal file? n
86 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
87 (branch merge, don't forget to commit)
88 $ hg ci -m 'merge lfs with largefiles -> normal'
89 $ hg manifest
90 large.bin
91 lfs.bin
92 lfs.txt
93 normal.txt
94
95 The merged lfs.bin resolved to lfs because the (n)ormal option was picked. The
96 lfs.txt file is unchanged by the merge, because it was added before lfs was
97 enabled, and the content didn't change.
98 $ hg debugdata lfs.bin 0
99 version https://git-lfs.github.com/spec/v1
100 oid sha256:81c7492b2c05e130431f65a87651b54a30c5da72c99ce35a1e9b9872a807312b
101 size 53
102 x-is-binary 0
103 $ hg debugdata lfs.txt 0
104 normal above lfs threshold 0000000000000000000000000
105
106 Another filelog entry is NOT made by the merge, so nothing is committed as lfs.
107 $ hg log -r . -T '{join(lfs_files, ", ")}\n'
108
109
110 Replay the last merge, but pick (l)arge this time. The manifest will show any
111 standins.
112
113 $ hg up -Cq e989d0fa3764
114
115 $ hg --config ui.interactive=True merge 6513aaab9ca0 <<EOF
116 > l
117 > l
118 > EOF
119 remote turned local normal file large.bin into a largefile
120 use (l)argefile or keep (n)ormal file? l
121 remote turned local normal file lfs.bin into a largefile
122 use (l)argefile or keep (n)ormal file? l
123 getting changed largefiles
124 2 largefiles updated, 0 removed
125 2 files updated, 0 files merged, 2 files removed, 0 files unresolved
126 (branch merge, don't forget to commit)
127 $ hg ci -m 'merge lfs with largefiles -> large'
128 created new head
129 $ hg manifest
130 .hglf/large.bin
131 .hglf/lfs.bin
132 lfs.txt
133 normal.txt
134
135 --------------------------------------------------------------------------------
136 Merge lfs into largefiles branch
137
138 $ hg up -Cq 6513aaab9ca0
139 $ hg --config ui.interactive=True merge e989d0fa3764 <<EOF
140 > n
141 > n
142 > EOF
143 remote turned local largefile large.bin into a normal file
144 keep (l)argefile or use (n)ormal file? n
145 remote turned local largefile lfs.bin into a normal file
146 keep (l)argefile or use (n)ormal file? n
147 getting changed largefiles
148 0 largefiles updated, 0 removed
149 2 files updated, 0 files merged, 2 files removed, 0 files unresolved
150 (branch merge, don't forget to commit)
151 $ hg ci -m 'merge largefiles with lfs -> normal'
152 created new head
153 $ hg manifest
154 large.bin
155 lfs.bin
156 lfs.txt
157 normal.txt
158
159 The merged lfs.bin got converted to lfs because the (n)ormal option was picked.
160 The lfs.txt file is unchanged by the merge, because it was added before lfs was
161 enabled.
162 $ hg debugdata lfs.bin 0
163 version https://git-lfs.github.com/spec/v1
164 oid sha256:81c7492b2c05e130431f65a87651b54a30c5da72c99ce35a1e9b9872a807312b
165 size 53
166 x-is-binary 0
167 $ hg debugdata lfs.txt 0
168 normal above lfs threshold 0000000000000000000000000
169
170 Another filelog entry is NOT made by the merge, so nothing is committed as lfs.
171 $ hg log -r . -T '{join(lfs_files, ", ")}\n'
172
173
174 Replay the last merge, but pick (l)arge this time. The manifest will show the
175 standins.
176
177 $ hg up -Cq 6513aaab9ca0
178
179 $ hg --config ui.interactive=True merge e989d0fa3764 <<EOF
180 > l
181 > l
182 > EOF
183 remote turned local largefile large.bin into a normal file
184 keep (l)argefile or use (n)ormal file? l
185 remote turned local largefile lfs.bin into a normal file
186 keep (l)argefile or use (n)ormal file? l
187 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
188 (branch merge, don't forget to commit)
189 $ hg ci -m 'merge largefiles with lfs -> large'
190 created new head
191 $ hg manifest
192 .hglf/large.bin
193 .hglf/lfs.bin
194 lfs.txt
195 normal.txt
196
197 --------------------------------------------------------------------------------
198
199 When both largefiles and lfs are configured to add by size, the tie goes to
200 largefiles since it hooks cmdutil.add() and lfs hooks the filelog write in the
201 commit. By the time the commit occurs, the tracked file is smaller than the
202 threshold (assuming it is > 41, so the standins don't become lfs objects).
203
204 $ "$PYTHON" -c 'import sys ; sys.stdout.write("y\n" * 1048576)' > large_by_size.bin
205 $ hg --config largefiles.minsize=1 ci -Am 'large by size'
206 adding large_by_size.bin as a largefile
207 $ hg manifest
208 .hglf/large.bin
209 .hglf/large_by_size.bin
210 .hglf/lfs.bin
211 lfs.txt
212 normal.txt
213
214 $ hg rm large_by_size.bin
215 $ hg ci -m 'remove large_by_size.bin'
216
217 Largefiles doesn't do anything special with diff, so it falls back to diffing
218 the standins. Extdiff also is standin based comparison. Diff and extdiff both
219 work on the original file for lfs objects.
220
221 Largefile -> lfs transition
222 $ hg diff -r 1 -r 3
223 diff -r 6513aaab9ca0 -r dcc5ce63e252 .hglf/large.bin
224 --- a/.hglf/large.bin Thu Jan 01 00:00:00 1970 +0000
225 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
226 @@ -1,1 +0,0 @@
227 -cef9a458373df9b0743a0d3c14d0c66fb19b8629
228 diff -r 6513aaab9ca0 -r dcc5ce63e252 .hglf/lfs.bin
229 --- a/.hglf/lfs.bin Thu Jan 01 00:00:00 1970 +0000
230 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
231 @@ -1,1 +0,0 @@
232 -557fb6309cef935e1ac2c8296508379e4b15a6e6
233 diff -r 6513aaab9ca0 -r dcc5ce63e252 large.bin
234 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
235 +++ b/large.bin Thu Jan 01 00:00:00 1970 +0000
236 @@ -0,0 +1,1 @@
237 +below lfs threshold
238 diff -r 6513aaab9ca0 -r dcc5ce63e252 lfs.bin
239 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
240 +++ b/lfs.bin Thu Jan 01 00:00:00 1970 +0000
241 @@ -0,0 +1,1 @@
242 +lfs above the lfs threshold for length 0000000000000
243
244 lfs -> largefiles transition
245 $ hg diff -r 2 -r 6
246 diff -r e989d0fa3764 -r 95e1e80325c8 .hglf/large.bin
247 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
248 +++ b/.hglf/large.bin Thu Jan 01 00:00:00 1970 +0000
249 @@ -0,0 +1,1 @@
250 +cef9a458373df9b0743a0d3c14d0c66fb19b8629
251 diff -r e989d0fa3764 -r 95e1e80325c8 .hglf/lfs.bin
252 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
253 +++ b/.hglf/lfs.bin Thu Jan 01 00:00:00 1970 +0000
254 @@ -0,0 +1,1 @@
255 +557fb6309cef935e1ac2c8296508379e4b15a6e6
256 diff -r e989d0fa3764 -r 95e1e80325c8 large.bin
257 --- a/large.bin Thu Jan 01 00:00:00 1970 +0000
258 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
259 @@ -1,1 +0,0 @@
260 -below lfs threshold
261 diff -r e989d0fa3764 -r 95e1e80325c8 lfs.bin
262 --- a/lfs.bin Thu Jan 01 00:00:00 1970 +0000
263 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
264 @@ -1,1 +0,0 @@
265 -lfs above the lfs threshold for length 0000000000000
266
267 A largefiles repo can be converted to lfs. The lfconvert command uses the
268 convert extension under the hood with --to-normal. So the --config based
269 parameters are available, but not --authormap, --branchmap, etc.
270
271 $ cd ..
272 $ hg lfconvert --to-normal largefiles nolargefiles 2>&1
273 initializing destination nolargefiles
274 0 additional largefiles cached
275 scanning source...
276 sorting...
277 converting...
278 8 normal.txt
279 7 add largefiles
280 6 add with lfs extension
281 5 merge lfs with largefiles -> normal
282 4 merge lfs with largefiles -> large
283 3 merge largefiles with lfs -> normal
284 2 merge largefiles with lfs -> large
285 1 large by size
286 0 remove large_by_size.bin
287 $ cd nolargefiles
288
289 The requirement is added to the destination repo.
290
291 $ hg debugrequires | grep lfs
292 lfs
293
294 $ hg log -r 'all()' -G -T '{rev} {join(lfs_files, ", ")} ({desc})\n'
295 o 8 large_by_size.bin (remove large_by_size.bin)
296 |
297 o 7 large_by_size.bin (large by size)
298 |
299 o 6 (merge largefiles with lfs -> large)
300 |\
301 +---o 5 (merge largefiles with lfs -> normal)
302 | |/
303 +---o 4 lfs.bin (merge lfs with largefiles -> large)
304 | |/
305 +---o 3 (merge lfs with largefiles -> normal)
306 | |/
307 | o 2 lfs.bin (add with lfs extension)
308 | |
309 o | 1 lfs.bin (add largefiles)
310 |/
311 o 0 lfs.txt (normal.txt)
312
313 $ hg debugdata lfs.bin 0
314 version https://git-lfs.github.com/spec/v1
315 oid sha256:2172a5bd492dd41ec533b9bb695f7691b6351719407ac797f0ccad5348c81e62
316 size 53
317 x-is-binary 0
318 $ hg debugdata lfs.bin 1
319 version https://git-lfs.github.com/spec/v1
320 oid sha256:81c7492b2c05e130431f65a87651b54a30c5da72c99ce35a1e9b9872a807312b
321 size 53
322 x-is-binary 0
323 $ hg debugdata lfs.bin 2
324 version https://git-lfs.github.com/spec/v1
325 oid sha256:2172a5bd492dd41ec533b9bb695f7691b6351719407ac797f0ccad5348c81e62
326 size 53
327 x-is-binary 0
328 $ hg debugdata lfs.bin 3
329 abort: invalid revision identifier 3
330 [255]
331
332 No diffs when comparing merge and p1 that kept p1's changes. Diff of lfs to
333 largefiles no longer operates in standin files.
334
335 This `head -n 20` looks dumb (since we expect no output), but if something
336 breaks you can get 1048576 lines of +y in the output, which takes a looooooong
337 time to print.
338 $ hg diff -r 2:3 | head -n 20
339 $ hg diff -r 2:6 | head -n 20
340 diff -r e989d0fa3764 -r 752e3a0d8488 large.bin
341 --- a/large.bin Thu Jan 01 00:00:00 1970 +0000
342 +++ b/large.bin Thu Jan 01 00:00:00 1970 +0000
343 @@ -1,1 +1,1 @@
344 -below lfs threshold
345 +largefile
346 diff -r e989d0fa3764 -r 752e3a0d8488 lfs.bin
347 --- a/lfs.bin Thu Jan 01 00:00:00 1970 +0000
348 +++ b/lfs.bin Thu Jan 01 00:00:00 1970 +0000
349 @@ -1,1 +1,1 @@
350 -lfs above the lfs threshold for length 0000000000000
351 +largefile above lfs threshold 0000000000000000000000