##// END OF EJS Templates
py3: string normalization and I/O tweaks in test-lfs.t...
Gregory Szorc -
r44570:2928d5af default
parent child Browse files
Show More
@@ -1,1231 +1,1237
1 1 #require no-reposimplestore no-chg
2 2
3 3 $ hg init requirements
4 4 $ cd requirements
5 5
6 6 # LFS not loaded by default.
7 7
8 8 $ hg config extensions
9 9 [1]
10 10
11 11 # Adding lfs to requires file will auto-load lfs extension.
12 12
13 13 $ echo lfs >> .hg/requires
14 14 $ hg config extensions
15 15 extensions.lfs=
16 16
17 17 # But only if there is no config entry for the extension already.
18 18
19 19 $ cat > .hg/hgrc << EOF
20 20 > [extensions]
21 21 > lfs=!
22 22 > EOF
23 23
24 24 $ hg config extensions
25 25 abort: repository requires features unknown to this Mercurial: lfs!
26 26 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
27 27 [255]
28 28
29 29 $ cat > .hg/hgrc << EOF
30 30 > [extensions]
31 31 > lfs=
32 32 > EOF
33 33
34 34 $ hg config extensions
35 35 extensions.lfs=
36 36
37 37 $ cat > .hg/hgrc << EOF
38 38 > [extensions]
39 39 > lfs = missing.py
40 40 > EOF
41 41
42 42 $ hg config extensions
43 43 \*\*\* failed to import extension lfs from missing.py: [Errno *] $ENOENT$: 'missing.py' (glob)
44 44 abort: repository requires features unknown to this Mercurial: lfs!
45 45 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
46 46 [255]
47 47
48 48 $ cd ..
49 49
50 50 # Initial setup
51 51
52 52 $ cat >> $HGRCPATH << EOF
53 53 > [extensions]
54 54 > lfs=
55 55 > [lfs]
56 56 > # Test deprecated config
57 57 > threshold=1000B
58 58 > EOF
59 59
60 60 $ LONG=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
61 61
62 62 # Prepare server and enable extension
63 63 $ hg init server
64 64 $ hg clone -q server client
65 65 $ cd client
66 66
67 67 # Commit small file
68 68 $ echo s > smallfile
69 69 $ echo '**.py = LF' > .hgeol
70 70 $ hg --config lfs.track='"size(\">1000B\")"' commit -Aqm "add small file"
71 71 hg: parse error: unsupported file pattern: size(">1000B")
72 72 (paths must be prefixed with "path:")
73 73 [255]
74 74 $ hg --config lfs.track='size(">1000B")' commit -Aqm "add small file"
75 75
76 76 # Commit large file
77 77 $ echo $LONG > largefile
78 78 $ grep lfs .hg/requires
79 79 [1]
80 80 $ hg commit --traceback -Aqm "add large file"
81 81 $ grep lfs .hg/requires
82 82 lfs
83 83
84 84 # Ensure metadata is stored
85 85 $ hg debugdata largefile 0
86 86 version https://git-lfs.github.com/spec/v1
87 87 oid sha256:f11e77c257047a398492d8d6cb9f6acf3aa7c4384bb23080b43546053e183e4b
88 88 size 1501
89 89 x-is-binary 0
90 90
91 91 # Check the blobstore is populated
92 92 $ find .hg/store/lfs/objects | sort
93 93 .hg/store/lfs/objects
94 94 .hg/store/lfs/objects/f1
95 95 .hg/store/lfs/objects/f1/1e77c257047a398492d8d6cb9f6acf3aa7c4384bb23080b43546053e183e4b
96 96
97 97 # Check the blob stored contains the actual contents of the file
98 98 $ cat .hg/store/lfs/objects/f1/1e77c257047a398492d8d6cb9f6acf3aa7c4384bb23080b43546053e183e4b
99 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CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
100 100
101 101 # Push changes to the server
102 102
103 103 $ hg push
104 104 pushing to $TESTTMP/server
105 105 searching for changes
106 106 abort: lfs.url needs to be configured
107 107 [255]
108 108
109 109 $ cat >> $HGRCPATH << EOF
110 110 > [lfs]
111 111 > url=file:$TESTTMP/dummy-remote/
112 112 > EOF
113 113
114 114 Push to a local non-lfs repo with the extension enabled will add the
115 115 lfs requirement
116 116
117 117 $ grep lfs $TESTTMP/server/.hg/requires
118 118 [1]
119 119 $ hg push -v | egrep -v '^(uncompressed| )'
120 120 pushing to $TESTTMP/server
121 121 searching for changes
122 122 lfs: found f11e77c257047a398492d8d6cb9f6acf3aa7c4384bb23080b43546053e183e4b in the local lfs store
123 123 2 changesets found
124 124 adding changesets
125 125 adding manifests
126 126 adding file changes
127 127 calling hook pretxnchangegroup.lfs: hgext.lfs.checkrequireslfs
128 128 added 2 changesets with 3 changes to 3 files
129 129 $ grep lfs $TESTTMP/server/.hg/requires
130 130 lfs
131 131
132 132 # Unknown URL scheme
133 133
134 134 $ hg push --config lfs.url=ftp://foobar
135 135 abort: lfs: unknown url scheme: ftp
136 136 [255]
137 137
138 138 $ cd ../
139 139
140 140 # Initialize new client (not cloning) and setup extension
141 141 $ hg init client2
142 142 $ cd client2
143 143 $ cat >> .hg/hgrc <<EOF
144 144 > [paths]
145 145 > default = $TESTTMP/server
146 146 > EOF
147 147
148 148 # Pull from server
149 149
150 150 Pulling a local lfs repo into a local non-lfs repo with the extension
151 151 enabled adds the lfs requirement
152 152
153 153 $ grep lfs .hg/requires $TESTTMP/server/.hg/requires
154 154 $TESTTMP/server/.hg/requires:lfs
155 155 $ hg pull default
156 156 pulling from $TESTTMP/server
157 157 requesting all changes
158 158 adding changesets
159 159 adding manifests
160 160 adding file changes
161 161 added 2 changesets with 3 changes to 3 files
162 162 new changesets 0ead593177f7:b88141481348
163 163 (run 'hg update' to get a working copy)
164 164 $ grep lfs .hg/requires $TESTTMP/server/.hg/requires
165 165 .hg/requires:lfs
166 166 $TESTTMP/server/.hg/requires:lfs
167 167
168 168 # Check the blobstore is not yet populated
169 169 $ [ -d .hg/store/lfs/objects ]
170 170 [1]
171 171
172 172 # Update to the last revision containing the large file
173 173 $ hg update
174 174 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
175 175
176 176 # Check the blobstore has been populated on update
177 177 $ find .hg/store/lfs/objects | sort
178 178 .hg/store/lfs/objects
179 179 .hg/store/lfs/objects/f1
180 180 .hg/store/lfs/objects/f1/1e77c257047a398492d8d6cb9f6acf3aa7c4384bb23080b43546053e183e4b
181 181
182 182 # Check the contents of the file are fetched from blobstore when requested
183 183 $ hg cat -r . largefile
184 184 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
189 189
190 190 $ cd ..
191 191
192 192 # Check rename, and switch between large and small files
193 193
194 194 $ hg init repo3
195 195 $ cd repo3
196 196 $ cat >> .hg/hgrc << EOF
197 197 > [lfs]
198 198 > track=size(">10B")
199 199 > EOF
200 200
201 201 $ echo LONGER-THAN-TEN-BYTES-WILL-TRIGGER-LFS > large
202 202 $ echo SHORTER > small
203 203 $ hg add . -q
204 204 $ hg commit -m 'commit with lfs content'
205 205
206 206 $ hg files -r . 'set:added()'
207 207 large
208 208 small
209 209 $ hg files -r . 'set:added() & lfs()'
210 210 large
211 211
212 212 $ hg mv large l
213 213 $ hg mv small s
214 214 $ hg status 'set:removed()'
215 215 R large
216 216 R small
217 217 $ hg status 'set:removed() & lfs()'
218 218 R large
219 219 $ hg commit -m 'renames'
220 220
221 221 $ hg cat -r . l -T '{rawdata}\n'
222 222 version https://git-lfs.github.com/spec/v1
223 223 oid sha256:66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
224 224 size 39
225 225 x-hg-copy large
226 226 x-hg-copyrev 2c531e0992ff3107c511b53cb82a91b6436de8b2
227 227 x-is-binary 0
228 228
229 229
230 230 $ hg files -r . 'set:copied()'
231 231 l
232 232 s
233 233 $ hg files -r . 'set:copied() & lfs()'
234 234 l
235 235 $ hg status --change . 'set:removed()'
236 236 R large
237 237 R small
238 238 $ hg status --change . 'set:removed() & lfs()'
239 239 R large
240 240
241 241 $ echo SHORT > l
242 242 $ echo BECOME-LARGER-FROM-SHORTER > s
243 243 $ hg commit -m 'large to small, small to large'
244 244
245 245 $ echo 1 >> l
246 246 $ echo 2 >> s
247 247 $ hg commit -m 'random modifications'
248 248
249 249 $ echo RESTORE-TO-BE-LARGE > l
250 250 $ echo SHORTER > s
251 251 $ hg commit -m 'switch large and small again'
252 252
253 253 # Test lfs_files template
254 254
255 255 $ hg log -r 'all()' -T '{rev} {join(lfs_files, ", ")}\n'
256 256 0 large
257 257 1 l, large
258 258 2 s
259 259 3 s
260 260 4 l
261 261
262 262 # Push and pull the above repo
263 263
264 264 $ hg --cwd .. init repo4
265 265 $ hg push ../repo4
266 266 pushing to ../repo4
267 267 searching for changes
268 268 adding changesets
269 269 adding manifests
270 270 adding file changes
271 271 added 5 changesets with 10 changes to 4 files
272 272
273 273 $ hg --cwd .. init repo5
274 274 $ hg --cwd ../repo5 pull ../repo3
275 275 pulling from ../repo3
276 276 requesting all changes
277 277 adding changesets
278 278 adding manifests
279 279 adding file changes
280 280 added 5 changesets with 10 changes to 4 files
281 281 new changesets fd47a419c4f7:5adf850972b9
282 282 (run 'hg update' to get a working copy)
283 283
284 284 $ cd ..
285 285
286 286 # Test clone
287 287
288 288 $ hg init repo6
289 289 $ cd repo6
290 290 $ cat >> .hg/hgrc << EOF
291 291 > [lfs]
292 292 > track=size(">30B")
293 293 > EOF
294 294
295 295 $ echo LARGE-BECAUSE-IT-IS-MORE-THAN-30-BYTES > large
296 296 $ echo SMALL > small
297 297 $ hg commit -Aqm 'create a lfs file' large small
298 298 $ hg debuglfsupload -r 'all()' -v
299 299 lfs: found 8e92251415339ae9b148c8da89ed5ec665905166a1ab11b09dca8fad83344738 in the local lfs store
300 300
301 301 $ cd ..
302 302
303 303 $ hg clone repo6 repo7
304 304 updating to branch default
305 305 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
306 306 $ cd repo7
307 307 $ cat large
308 308 LARGE-BECAUSE-IT-IS-MORE-THAN-30-BYTES
309 309 $ cat small
310 310 SMALL
311 311
312 312 $ cd ..
313 313
314 314 $ hg --config extensions.share= share repo7 sharedrepo
315 315 updating working directory
316 316 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
317 317 $ grep lfs sharedrepo/.hg/requires
318 318 lfs
319 319
320 320 # Test rename and status
321 321
322 322 $ hg init repo8
323 323 $ cd repo8
324 324 $ cat >> .hg/hgrc << EOF
325 325 > [lfs]
326 326 > track=size(">10B")
327 327 > EOF
328 328
329 329 $ echo THIS-IS-LFS-BECAUSE-10-BYTES > a1
330 330 $ echo SMALL > a2
331 331 $ hg commit -m a -A a1 a2
332 332 $ hg status
333 333 $ hg mv a1 b1
334 334 $ hg mv a2 a1
335 335 $ hg mv b1 a2
336 336 $ hg commit -m b
337 337 $ hg status
338 338 >>> with open('a2', 'wb') as f:
339 339 ... f.write(b'\1\nSTART-WITH-HG-FILELOG-METADATA') and None
340 340 >>> with open('a1', 'wb') as f:
341 341 ... f.write(b'\1\nMETA\n') and None
342 342 $ hg commit -m meta
343 343 $ hg status
344 344 $ hg log -T '{rev}: {file_copies} | {file_dels} | {file_adds}\n'
345 345 2: | |
346 346 1: a1 (a2)a2 (a1) | |
347 347 0: | | a1 a2
348 348
349 349 $ for n in a1 a2; do
350 350 > for r in 0 1 2; do
351 351 > printf '\n%s @ %s\n' $n $r
352 352 > hg debugdata $n $r
353 353 > done
354 354 > done
355 355
356 356 a1 @ 0
357 357 version https://git-lfs.github.com/spec/v1
358 358 oid sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
359 359 size 29
360 360 x-is-binary 0
361 361
362 362 a1 @ 1
363 363 \x01 (esc)
364 364 copy: a2
365 365 copyrev: 50470ad23cf937b1f4b9f80bfe54df38e65b50d9
366 366 \x01 (esc)
367 367 SMALL
368 368
369 369 a1 @ 2
370 370 \x01 (esc)
371 371 \x01 (esc)
372 372 \x01 (esc)
373 373 META
374 374
375 375 a2 @ 0
376 376 SMALL
377 377
378 378 a2 @ 1
379 379 version https://git-lfs.github.com/spec/v1
380 380 oid sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
381 381 size 29
382 382 x-hg-copy a1
383 383 x-hg-copyrev be23af27908a582af43e5cda209a5a9b319de8d4
384 384 x-is-binary 0
385 385
386 386 a2 @ 2
387 387 version https://git-lfs.github.com/spec/v1
388 388 oid sha256:876dadc86a8542f9798048f2c47f51dbf8e4359aed883e8ec80c5db825f0d943
389 389 size 32
390 390 x-is-binary 0
391 391
392 392 # Verify commit hashes include rename metadata
393 393
394 394 $ hg log -T '{rev}:{node|short} {desc}\n'
395 395 2:0fae949de7fa meta
396 396 1:9cd6bdffdac0 b
397 397 0:7f96794915f7 a
398 398
399 399 $ cd ..
400 400
401 401 # Test bundle
402 402
403 403 $ hg init repo9
404 404 $ cd repo9
405 405 $ cat >> .hg/hgrc << EOF
406 406 > [lfs]
407 407 > track=size(">10B")
408 408 > [diff]
409 409 > git=1
410 410 > EOF
411 411
412 412 $ for i in 0 single two three 4; do
413 413 > echo 'THIS-IS-LFS-'$i > a
414 414 > hg commit -m a-$i -A a
415 415 > done
416 416
417 417 $ hg update 2 -q
418 418 $ echo 'THIS-IS-LFS-2-CHILD' > a
419 419 $ hg commit -m branching -q
420 420
421 421 $ hg bundle --base 1 bundle.hg -v
422 422 lfs: found 5ab7a3739a5feec94a562d070a14f36dba7cad17e5484a4a89eea8e5f3166888 in the local lfs store
423 423 lfs: found a9c7d1cd6ce2b9bbdf46ed9a862845228717b921c089d0d42e3bcaed29eb612e in the local lfs store
424 424 lfs: found f693890c49c409ec33673b71e53f297681f76c1166daf33b2ad7ebf8b1d3237e in the local lfs store
425 425 lfs: found fda198fea753eb66a252e9856915e1f5cddbe41723bd4b695ece2604ad3c9f75 in the local lfs store
426 426 4 changesets found
427 427 uncompressed size of bundle content:
428 428 * (changelog) (glob)
429 429 * (manifests) (glob)
430 430 * a (glob)
431 431 $ hg --config extensions.strip= strip -r 2 --no-backup --force -q
432 432 $ hg -R bundle.hg log -p -T '{rev} {desc}\n' a
433 433 5 branching
434 434 diff --git a/a b/a
435 435 --- a/a
436 436 +++ b/a
437 437 @@ -1,1 +1,1 @@
438 438 -THIS-IS-LFS-two
439 439 +THIS-IS-LFS-2-CHILD
440 440
441 441 4 a-4
442 442 diff --git a/a b/a
443 443 --- a/a
444 444 +++ b/a
445 445 @@ -1,1 +1,1 @@
446 446 -THIS-IS-LFS-three
447 447 +THIS-IS-LFS-4
448 448
449 449 3 a-three
450 450 diff --git a/a b/a
451 451 --- a/a
452 452 +++ b/a
453 453 @@ -1,1 +1,1 @@
454 454 -THIS-IS-LFS-two
455 455 +THIS-IS-LFS-three
456 456
457 457 2 a-two
458 458 diff --git a/a b/a
459 459 --- a/a
460 460 +++ b/a
461 461 @@ -1,1 +1,1 @@
462 462 -THIS-IS-LFS-single
463 463 +THIS-IS-LFS-two
464 464
465 465 1 a-single
466 466 diff --git a/a b/a
467 467 --- a/a
468 468 +++ b/a
469 469 @@ -1,1 +1,1 @@
470 470 -THIS-IS-LFS-0
471 471 +THIS-IS-LFS-single
472 472
473 473 0 a-0
474 474 diff --git a/a b/a
475 475 new file mode 100644
476 476 --- /dev/null
477 477 +++ b/a
478 478 @@ -0,0 +1,1 @@
479 479 +THIS-IS-LFS-0
480 480
481 481 $ hg bundle -R bundle.hg --base 1 bundle-again.hg -q
482 482 $ hg -R bundle-again.hg log -p -T '{rev} {desc}\n' a
483 483 5 branching
484 484 diff --git a/a b/a
485 485 --- a/a
486 486 +++ b/a
487 487 @@ -1,1 +1,1 @@
488 488 -THIS-IS-LFS-two
489 489 +THIS-IS-LFS-2-CHILD
490 490
491 491 4 a-4
492 492 diff --git a/a b/a
493 493 --- a/a
494 494 +++ b/a
495 495 @@ -1,1 +1,1 @@
496 496 -THIS-IS-LFS-three
497 497 +THIS-IS-LFS-4
498 498
499 499 3 a-three
500 500 diff --git a/a b/a
501 501 --- a/a
502 502 +++ b/a
503 503 @@ -1,1 +1,1 @@
504 504 -THIS-IS-LFS-two
505 505 +THIS-IS-LFS-three
506 506
507 507 2 a-two
508 508 diff --git a/a b/a
509 509 --- a/a
510 510 +++ b/a
511 511 @@ -1,1 +1,1 @@
512 512 -THIS-IS-LFS-single
513 513 +THIS-IS-LFS-two
514 514
515 515 1 a-single
516 516 diff --git a/a b/a
517 517 --- a/a
518 518 +++ b/a
519 519 @@ -1,1 +1,1 @@
520 520 -THIS-IS-LFS-0
521 521 +THIS-IS-LFS-single
522 522
523 523 0 a-0
524 524 diff --git a/a b/a
525 525 new file mode 100644
526 526 --- /dev/null
527 527 +++ b/a
528 528 @@ -0,0 +1,1 @@
529 529 +THIS-IS-LFS-0
530 530
531 531 $ cd ..
532 532
533 533 # Test isbinary
534 534
535 535 $ hg init repo10
536 536 $ cd repo10
537 537 $ cat >> .hg/hgrc << EOF
538 538 > [extensions]
539 539 > lfs=
540 540 > [lfs]
541 541 > track=all()
542 542 > EOF
543 543 $ "$PYTHON" <<'EOF'
544 544 > def write(path, content):
545 545 > with open(path, 'wb') as f:
546 546 > f.write(content)
547 547 > write('a', b'\0\0')
548 548 > write('b', b'\1\n')
549 549 > write('c', b'\1\n\0')
550 550 > write('d', b'xx')
551 551 > EOF
552 552 $ hg add a b c d
553 553 $ hg diff --stat
554 554 a | Bin
555 555 b | 1 +
556 556 c | Bin
557 557 d | 1 +
558 558 4 files changed, 2 insertions(+), 0 deletions(-)
559 559 $ hg commit -m binarytest
560 560 $ cat > $TESTTMP/dumpbinary.py << EOF
561 561 > from mercurial.utils import (
562 562 > stringutil,
563 563 > )
564 564 > def reposetup(ui, repo):
565 565 > for n in (b'a', b'b', b'c', b'd'):
566 566 > ui.write((b'%s: binary=%s\n')
567 567 > % (n, stringutil.pprint(repo[b'.'][n].isbinary())))
568 568 > EOF
569 569 $ hg --config extensions.dumpbinary=$TESTTMP/dumpbinary.py id --trace
570 570 a: binary=True
571 571 b: binary=False
572 572 c: binary=True
573 573 d: binary=False
574 574 b55353847f02 tip
575 575
576 576 Binary blobs don't need to be present to be skipped in filesets. (And their
577 577 absence doesn't cause an abort.)
578 578
579 579 $ rm .hg/store/lfs/objects/96/a296d224f285c67bee93c30f8a309157f0daa35dc5b87e410b78630a09cfc7
580 580 $ rm .hg/store/lfs/objects/92/f76135a4baf4faccb8586a60faf830c2bdfce147cefa188aaf4b790bd01b7e
581 581
582 582 $ hg files --debug -r . 'set:eol("unix")' --config 'experimental.lfs.disableusercache=True'
583 583 lfs: found c04b5bb1a5b2eb3e9cd4805420dba5a9d133da5b7adeeafb5474c4adae9faa80 in the local lfs store
584 584 2 b
585 585 lfs: found 5dde896887f6754c9b15bfe3a441ae4806df2fde94001311e08bf110622e0bbe in the local lfs store
586 586
587 587 $ hg files --debug -r . 'set:binary()' --config 'experimental.lfs.disableusercache=True'
588 588 2 a
589 589 3 c
590 590
591 591 $ cd ..
592 592
593 593 # Test fctx.cmp fastpath - diff without LFS blobs
594 594
595 595 $ hg init repo12
596 596 $ cd repo12
597 597 $ cat >> .hg/hgrc <<EOF
598 598 > [lfs]
599 599 > threshold=1
600 600 > EOF
601 601 $ cat > ../patch.diff <<EOF
602 602 > # HG changeset patch
603 603 > 2
604 604 >
605 605 > diff --git a/a b/a
606 606 > old mode 100644
607 607 > new mode 100755
608 608 > EOF
609 609
610 610 $ for i in 1 2 3; do
611 611 > cp ../repo10/a a
612 612 > if [ $i = 3 ]; then
613 613 > # make a content-only change
614 614 > hg import -q --bypass ../patch.diff
615 615 > hg update -q
616 616 > rm ../patch.diff
617 617 > else
618 618 > echo $i >> a
619 619 > hg commit -m $i -A a
620 620 > fi
621 621 > done
622 622 $ [ -d .hg/store/lfs/objects ]
623 623
624 624 $ cd ..
625 625
626 626 $ hg clone repo12 repo13 --noupdate
627 627 $ cd repo13
628 628 $ hg log --removed -p a -T '{desc}\n' --config diff.nobinary=1 --git
629 629 2
630 630 diff --git a/a b/a
631 631 old mode 100644
632 632 new mode 100755
633 633
634 634 2
635 635 diff --git a/a b/a
636 636 Binary file a has changed
637 637
638 638 1
639 639 diff --git a/a b/a
640 640 new file mode 100644
641 641 Binary file a has changed
642 642
643 643 $ [ -d .hg/store/lfs/objects ]
644 644 [1]
645 645
646 646 $ cd ..
647 647
648 648 # Test filter
649 649
650 650 $ hg init repo11
651 651 $ cd repo11
652 652 $ cat >> .hg/hgrc << EOF
653 653 > [lfs]
654 654 > track=(**.a & size(">5B")) | (**.b & !size(">5B"))
655 655 > | (**.c & "path:d" & !"path:d/c.c") | size(">10B")
656 656 > EOF
657 657
658 658 $ mkdir a
659 659 $ echo aaaaaa > a/1.a
660 660 $ echo a > a/2.a
661 661 $ echo aaaaaa > 1.b
662 662 $ echo a > 2.b
663 663 $ echo a > 1.c
664 664 $ mkdir d
665 665 $ echo a > d/c.c
666 666 $ echo a > d/d.c
667 667 $ echo aaaaaaaaaaaa > x
668 668 $ hg add . -q
669 669 $ hg commit -m files
670 670
671 671 $ for p in a/1.a a/2.a 1.b 2.b 1.c d/c.c d/d.c x; do
672 672 > if hg debugdata $p 0 2>&1 | grep git-lfs >/dev/null; then
673 673 > echo "${p}: is lfs"
674 674 > else
675 675 > echo "${p}: not lfs"
676 676 > fi
677 677 > done
678 678 a/1.a: is lfs
679 679 a/2.a: not lfs
680 680 1.b: not lfs
681 681 2.b: is lfs
682 682 1.c: not lfs
683 683 d/c.c: not lfs
684 684 d/d.c: is lfs
685 685 x: is lfs
686 686
687 687 $ cd ..
688 688
689 689 # Verify the repos
690 690
691 691 $ cat > $TESTTMP/dumpflog.py << EOF
692 692 > # print raw revision sizes, flags, and hashes for certain files
693 693 > import hashlib
694 694 > from mercurial.node import short
695 695 > from mercurial import (
696 696 > pycompat,
697 697 > revlog,
698 698 > )
699 699 > from mercurial.utils import (
700 700 > stringutil,
701 701 > )
702 702 > def hash(rawtext):
703 703 > h = hashlib.sha512()
704 704 > h.update(rawtext)
705 705 > return pycompat.sysbytes(h.hexdigest()[:4])
706 706 > def reposetup(ui, repo):
707 707 > # these 2 files are interesting
708 708 > for name in [b'l', b's']:
709 709 > fl = repo.file(name)
710 710 > if len(fl) == 0:
711 711 > continue
712 712 > sizes = [fl._revlog.rawsize(i) for i in fl]
713 713 > texts = [fl.rawdata(i) for i in fl]
714 714 > flags = [int(fl._revlog.flags(i)) for i in fl]
715 715 > hashes = [hash(t) for t in texts]
716 716 > pycompat.stdout.write(b' %s: rawsizes=%r flags=%r hashes=%s\n'
717 717 > % (name, sizes, flags, stringutil.pprint(hashes)))
718 718 > EOF
719 719
720 720 $ for i in client client2 server repo3 repo4 repo5 repo6 repo7 repo8 repo9 \
721 721 > repo10; do
722 722 > echo 'repo:' $i
723 723 > hg --cwd $i verify --config extensions.dumpflog=$TESTTMP/dumpflog.py -q
724 724 > done
725 725 repo: client
726 726 repo: client2
727 727 repo: server
728 728 repo: repo3
729 729 l: rawsizes=[211, 6, 8, 141] flags=[8192, 0, 0, 8192] hashes=['d2b8', '948c', 'cc88', '724d']
730 730 s: rawsizes=[74, 141, 141, 8] flags=[0, 8192, 8192, 0] hashes=['3c80', 'fce0', '874a', '826b']
731 731 repo: repo4
732 732 l: rawsizes=[211, 6, 8, 141] flags=[8192, 0, 0, 8192] hashes=['d2b8', '948c', 'cc88', '724d']
733 733 s: rawsizes=[74, 141, 141, 8] flags=[0, 8192, 8192, 0] hashes=['3c80', 'fce0', '874a', '826b']
734 734 repo: repo5
735 735 l: rawsizes=[211, 6, 8, 141] flags=[8192, 0, 0, 8192] hashes=['d2b8', '948c', 'cc88', '724d']
736 736 s: rawsizes=[74, 141, 141, 8] flags=[0, 8192, 8192, 0] hashes=['3c80', 'fce0', '874a', '826b']
737 737 repo: repo6
738 738 repo: repo7
739 739 repo: repo8
740 740 repo: repo9
741 741 repo: repo10
742 742
743 743 repo13 doesn't have any cached lfs files and its source never pushed its
744 744 files. Therefore, the files don't exist in the remote store. Use the files in
745 745 the user cache.
746 746
747 747 $ test -d $TESTTMP/repo13/.hg/store/lfs/objects
748 748 [1]
749 749
750 750 $ hg --config extensions.share= share repo13 repo14
751 751 updating working directory
752 752 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
753 753 $ hg -R repo14 -q verify
754 754
755 755 $ hg clone repo13 repo15
756 756 updating to branch default
757 757 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
758 758 $ hg -R repo15 -q verify
759 759
760 760 If the source repo doesn't have the blob (maybe it was pulled or cloned with
761 761 --noupdate), the blob is still accessible via the global cache to send to the
762 762 remote store.
763 763
764 764 $ rm -rf $TESTTMP/repo15/.hg/store/lfs
765 765 $ hg init repo16
766 766 $ hg -R repo15 push repo16
767 767 pushing to repo16
768 768 searching for changes
769 769 adding changesets
770 770 adding manifests
771 771 adding file changes
772 772 added 3 changesets with 2 changes to 1 files
773 773 $ hg -R repo15 -q verify
774 774
775 775 Test damaged file scenarios. (This also damages the usercache because of the
776 776 hardlinks.)
777 777
778 778 $ echo 'damage' >> repo5/.hg/store/lfs/objects/66/100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
779 779
780 780 Repo with damaged lfs objects in any revision will fail verification.
781 781
782 782 $ hg -R repo5 verify
783 783 checking changesets
784 784 checking manifests
785 785 crosschecking files in changesets and manifests
786 786 checking files
787 787 l@1: unpacking 46a2f24864bc: integrity check failed on data/l.i:0
788 788 large@0: unpacking 2c531e0992ff: integrity check failed on data/large.i:0
789 789 checked 5 changesets with 10 changes to 4 files
790 790 2 integrity errors encountered!
791 791 (first damaged changeset appears to be 0)
792 792 [1]
793 793
794 794 Updates work after cloning a damaged repo, if the damaged lfs objects aren't in
795 795 the update destination. Those objects won't be added to the new repo's store
796 796 because they aren't accessed.
797 797
798 798 $ hg clone -v repo5 fromcorrupt
799 799 updating to branch default
800 800 resolving manifests
801 801 getting l
802 802 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the usercache
803 803 getting s
804 804 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
805 805 $ test -f fromcorrupt/.hg/store/lfs/objects/66/100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
806 806 [1]
807 807
808 808 Verify will not try to download lfs blobs, if told not to process lfs content.
809 809 The extension makes sure that the filelog.renamed() path is taken on a missing
810 810 blob, and the output shows that it isn't fetched.
811 811
812 812 $ cat > $TESTTMP/lfsrename.py <<EOF
813 > import sys
814 >
813 815 > from mercurial import (
814 816 > exthelper,
817 > pycompat,
815 818 > )
816 819 >
817 820 > from hgext.lfs import (
818 821 > pointer,
819 822 > wrapper,
820 823 > )
821 824 >
822 825 > eh = exthelper.exthelper()
823 826 > uisetup = eh.finaluisetup
824 827 >
825 828 > @eh.wrapfunction(wrapper, b'filelogrenamed')
826 829 > def filelogrenamed(orig, orig1, self, node):
827 830 > ret = orig(orig1, self, node)
828 831 > if wrapper._islfs(self._revlog, node) and ret:
829 832 > rawtext = self._revlog.rawdata(node)
830 833 > metadata = pointer.deserialize(rawtext)
831 834 > print('lfs blob %s renamed %s -> %s'
832 > % (metadata[b'oid'], ret[0], self._revlog.filename))
835 > % (pycompat.sysstr(metadata[b'oid']),
836 > pycompat.sysstr(ret[0]),
837 > pycompat.fsdecode(self._revlog.filename)))
838 > sys.stdout.flush()
833 839 > return ret
834 840 > EOF
835 841
836 842 $ hg -R fromcorrupt --config lfs.usercache=emptycache verify -v --no-lfs \
837 843 > --config extensions.x=$TESTTMP/lfsrename.py
838 844 repository uses revlog format 1
839 845 checking changesets
840 846 checking manifests
841 847 crosschecking files in changesets and manifests
842 848 checking files
843 849 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
844 850 lfs blob sha256:66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e renamed large -> l
845 851 checked 5 changesets with 10 changes to 4 files
846 852
847 853 Verify will not try to download lfs blobs, if told not to by the config option
848 854
849 855 $ hg -R fromcorrupt --config lfs.usercache=emptycache verify -v \
850 856 > --config verify.skipflags=8192 \
851 857 > --config extensions.x=$TESTTMP/lfsrename.py
852 858 repository uses revlog format 1
853 859 checking changesets
854 860 checking manifests
855 861 crosschecking files in changesets and manifests
856 862 checking files
857 863 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
858 864 lfs blob sha256:66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e renamed large -> l
859 865 checked 5 changesets with 10 changes to 4 files
860 866
861 867 Verify will copy/link all lfs objects into the local store that aren't already
862 868 present. Bypass the corrupted usercache to show that verify works when fed by
863 869 the (uncorrupted) remote store.
864 870
865 871 $ hg -R fromcorrupt --config lfs.usercache=emptycache verify -v
866 872 repository uses revlog format 1
867 873 checking changesets
868 874 checking manifests
869 875 crosschecking files in changesets and manifests
870 876 checking files
871 877 lfs: adding 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e to the usercache
872 878 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the local lfs store
873 879 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
874 880 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the local lfs store
875 881 lfs: adding 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 to the usercache
876 882 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
877 883 lfs: adding b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c to the usercache
878 884 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
879 885 checked 5 changesets with 10 changes to 4 files
880 886
881 887 Verify will not copy/link a corrupted file from the usercache into the local
882 888 store, and poison it. (The verify with a good remote now works.)
883 889
884 890 $ rm -r fromcorrupt/.hg/store/lfs/objects/66/100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
885 891 $ hg -R fromcorrupt verify -v
886 892 repository uses revlog format 1
887 893 checking changesets
888 894 checking manifests
889 895 crosschecking files in changesets and manifests
890 896 checking files
891 897 l@1: unpacking 46a2f24864bc: integrity check failed on data/l.i:0
892 898 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
893 899 large@0: unpacking 2c531e0992ff: integrity check failed on data/large.i:0
894 900 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
895 901 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
896 902 checked 5 changesets with 10 changes to 4 files
897 903 2 integrity errors encountered!
898 904 (first damaged changeset appears to be 0)
899 905 [1]
900 906 $ hg -R fromcorrupt --config lfs.usercache=emptycache verify -v
901 907 repository uses revlog format 1
902 908 checking changesets
903 909 checking manifests
904 910 crosschecking files in changesets and manifests
905 911 checking files
906 912 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the usercache
907 913 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
908 914 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the local lfs store
909 915 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
910 916 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
911 917 checked 5 changesets with 10 changes to 4 files
912 918
913 919 Damaging a file required by the update destination fails the update.
914 920
915 921 $ echo 'damage' >> $TESTTMP/dummy-remote/22/f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b
916 922 $ hg --config lfs.usercache=emptycache clone -v repo5 fromcorrupt2
917 923 updating to branch default
918 924 resolving manifests
919 925 abort: corrupt remote lfs object: 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b
920 926 [255]
921 927
922 928 A corrupted lfs blob is not transferred from a file://remotestore to the
923 929 usercache or local store.
924 930
925 931 $ test -f emptycache/22/f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b
926 932 [1]
927 933 $ test -f fromcorrupt2/.hg/store/lfs/objects/22/f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b
928 934 [1]
929 935
930 936 $ hg -R fromcorrupt2 verify
931 937 checking changesets
932 938 checking manifests
933 939 crosschecking files in changesets and manifests
934 940 checking files
935 941 l@1: unpacking 46a2f24864bc: integrity check failed on data/l.i:0
936 942 large@0: unpacking 2c531e0992ff: integrity check failed on data/large.i:0
937 943 checked 5 changesets with 10 changes to 4 files
938 944 2 integrity errors encountered!
939 945 (first damaged changeset appears to be 0)
940 946 [1]
941 947
942 948 Corrupt local files are not sent upstream. (The alternate dummy remote
943 949 avoids the corrupt lfs object in the original remote.)
944 950
945 951 $ mkdir $TESTTMP/dummy-remote2
946 952 $ hg init dest
947 953 $ hg -R fromcorrupt2 --config lfs.url=file:///$TESTTMP/dummy-remote2 push -v dest
948 954 pushing to dest
949 955 searching for changes
950 956 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
951 957 abort: detected corrupt lfs object: 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
952 958 (run hg verify)
953 959 [255]
954 960
955 961 $ hg -R fromcorrupt2 --config lfs.url=file:///$TESTTMP/dummy-remote2 verify -v
956 962 repository uses revlog format 1
957 963 checking changesets
958 964 checking manifests
959 965 crosschecking files in changesets and manifests
960 966 checking files
961 967 l@1: unpacking 46a2f24864bc: integrity check failed on data/l.i:0
962 968 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
963 969 large@0: unpacking 2c531e0992ff: integrity check failed on data/large.i:0
964 970 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
965 971 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
966 972 checked 5 changesets with 10 changes to 4 files
967 973 2 integrity errors encountered!
968 974 (first damaged changeset appears to be 0)
969 975 [1]
970 976
971 977 $ cat $TESTTMP/dummy-remote2/22/f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b | $TESTDIR/f --sha256
972 978 sha256=22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b
973 979 $ cat fromcorrupt2/.hg/store/lfs/objects/22/f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b | $TESTDIR/f --sha256
974 980 sha256=22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b
975 981 $ test -f $TESTTMP/dummy-remote2/66/100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
976 982 [1]
977 983
978 984 Accessing a corrupt file will complain
979 985
980 986 $ hg --cwd fromcorrupt2 cat -r 0 large
981 987 abort: integrity check failed on data/large.i:0!
982 988 [255]
983 989
984 990 lfs -> normal -> lfs round trip conversions are possible. The 'none()'
985 991 predicate on the command line will override whatever is configured globally and
986 992 locally, and ensures everything converts to a regular file. For lfs -> normal,
987 993 there's no 'lfs' destination repo requirement. For normal -> lfs, there is.
988 994
989 995 $ hg --config extensions.convert= --config 'lfs.track=none()' \
990 996 > convert repo8 convert_normal
991 997 initializing destination convert_normal repository
992 998 scanning source...
993 999 sorting...
994 1000 converting...
995 1001 2 a
996 1002 1 b
997 1003 0 meta
998 1004 $ grep 'lfs' convert_normal/.hg/requires
999 1005 [1]
1000 1006 $ hg --cwd convert_normal cat a1 -r 0 -T '{rawdata}'
1001 1007 THIS-IS-LFS-BECAUSE-10-BYTES
1002 1008
1003 1009 $ hg --config extensions.convert= --config lfs.threshold=10B \
1004 1010 > convert convert_normal convert_lfs
1005 1011 initializing destination convert_lfs repository
1006 1012 scanning source...
1007 1013 sorting...
1008 1014 converting...
1009 1015 2 a
1010 1016 1 b
1011 1017 0 meta
1012 1018
1013 1019 $ hg --cwd convert_lfs cat -r 0 a1 -T '{rawdata}'
1014 1020 version https://git-lfs.github.com/spec/v1
1015 1021 oid sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
1016 1022 size 29
1017 1023 x-is-binary 0
1018 1024 $ hg --cwd convert_lfs debugdata a1 0
1019 1025 version https://git-lfs.github.com/spec/v1
1020 1026 oid sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
1021 1027 size 29
1022 1028 x-is-binary 0
1023 1029 $ hg --cwd convert_lfs log -r 0 -T "{lfs_files % '{lfspointer % '{key}={value}\n'}'}"
1024 1030 version=https://git-lfs.github.com/spec/v1
1025 1031 oid=sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
1026 1032 size=29
1027 1033 x-is-binary=0
1028 1034 $ hg --cwd convert_lfs log -r 0 \
1029 1035 > -T '{lfs_files % "{get(lfspointer, "oid")}\n"}{lfs_files % "{lfspointer.oid}\n"}'
1030 1036 sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
1031 1037 sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
1032 1038 $ hg --cwd convert_lfs log -r 0 -T '{lfs_files % "{lfspointer}\n"}'
1033 1039 version=https://git-lfs.github.com/spec/v1 oid=sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024 size=29 x-is-binary=0
1034 1040 $ hg --cwd convert_lfs \
1035 1041 > log -r 'all()' -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}'
1036 1042 0: a1: 5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
1037 1043 1: a2: 5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
1038 1044 2: a2: 876dadc86a8542f9798048f2c47f51dbf8e4359aed883e8ec80c5db825f0d943
1039 1045
1040 1046 $ grep 'lfs' convert_lfs/.hg/requires
1041 1047 lfs
1042 1048
1043 1049 The hashes in all stages of the conversion are unchanged.
1044 1050
1045 1051 $ hg -R repo8 log -T '{node|short}\n'
1046 1052 0fae949de7fa
1047 1053 9cd6bdffdac0
1048 1054 7f96794915f7
1049 1055 $ hg -R convert_normal log -T '{node|short}\n'
1050 1056 0fae949de7fa
1051 1057 9cd6bdffdac0
1052 1058 7f96794915f7
1053 1059 $ hg -R convert_lfs log -T '{node|short}\n'
1054 1060 0fae949de7fa
1055 1061 9cd6bdffdac0
1056 1062 7f96794915f7
1057 1063
1058 1064 This convert is trickier, because it contains deleted files (via `hg mv`)
1059 1065
1060 1066 $ hg --config extensions.convert= --config lfs.threshold=1000M \
1061 1067 > convert repo3 convert_normal2
1062 1068 initializing destination convert_normal2 repository
1063 1069 scanning source...
1064 1070 sorting...
1065 1071 converting...
1066 1072 4 commit with lfs content
1067 1073 3 renames
1068 1074 2 large to small, small to large
1069 1075 1 random modifications
1070 1076 0 switch large and small again
1071 1077 $ grep 'lfs' convert_normal2/.hg/requires
1072 1078 [1]
1073 1079 $ hg --cwd convert_normal2 debugdata large 0
1074 1080 LONGER-THAN-TEN-BYTES-WILL-TRIGGER-LFS
1075 1081
1076 1082 $ hg --config extensions.convert= --config lfs.threshold=10B \
1077 1083 > convert convert_normal2 convert_lfs2
1078 1084 initializing destination convert_lfs2 repository
1079 1085 scanning source...
1080 1086 sorting...
1081 1087 converting...
1082 1088 4 commit with lfs content
1083 1089 3 renames
1084 1090 2 large to small, small to large
1085 1091 1 random modifications
1086 1092 0 switch large and small again
1087 1093 $ grep 'lfs' convert_lfs2/.hg/requires
1088 1094 lfs
1089 1095 $ hg --cwd convert_lfs2 debugdata large 0
1090 1096 version https://git-lfs.github.com/spec/v1
1091 1097 oid sha256:66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
1092 1098 size 39
1093 1099 x-is-binary 0
1094 1100
1095 1101 Committing deleted files works:
1096 1102
1097 1103 $ hg init $TESTTMP/repo-del
1098 1104 $ cd $TESTTMP/repo-del
1099 1105 $ echo 1 > A
1100 1106 $ hg commit -m 'add A' -A A
1101 1107 $ hg rm A
1102 1108 $ hg commit -m 'rm A'
1103 1109
1104 1110 Bad .hglfs files will block the commit with a useful message
1105 1111
1106 1112 $ cat > .hglfs << EOF
1107 1113 > [track]
1108 1114 > **.test = size(">5B")
1109 1115 > bad file ... no commit
1110 1116 > EOF
1111 1117
1112 1118 $ echo x > file.txt
1113 1119 $ hg ci -Aqm 'should fail'
1114 1120 hg: parse error at .hglfs:3: bad file ... no commit
1115 1121 [255]
1116 1122
1117 1123 $ cat > .hglfs << EOF
1118 1124 > [track]
1119 1125 > **.test = size(">5B")
1120 1126 > ** = nonexistent()
1121 1127 > EOF
1122 1128
1123 1129 $ hg ci -Aqm 'should fail'
1124 1130 abort: parse error in .hglfs: unknown identifier: nonexistent
1125 1131 [255]
1126 1132
1127 1133 '**' works out to mean all files.
1128 1134
1129 1135 $ cat > .hglfs << EOF
1130 1136 > [track]
1131 1137 > path:.hglfs = none()
1132 1138 > **.test = size(">5B")
1133 1139 > **.exclude = none()
1134 1140 > ** = size(">10B")
1135 1141 > EOF
1136 1142
1137 1143 The LFS policy takes effect without tracking the .hglfs file
1138 1144
1139 1145 $ echo 'largefile' > lfs.test
1140 1146 $ echo '012345678901234567890' > nolfs.exclude
1141 1147 $ echo '01234567890123456' > lfs.catchall
1142 1148 $ hg add *
1143 1149 $ hg ci -qm 'before add .hglfs'
1144 1150 $ hg log -r . -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}\n'
1145 1151 2: lfs.catchall: d4ec46c2869ba22eceb42a729377432052d9dd75d82fc40390ebaadecee87ee9
1146 1152 lfs.test: 5489e6ced8c36a7b267292bde9fd5242a5f80a7482e8f23fa0477393dfaa4d6c
1147 1153
1148 1154 The .hglfs file works when tracked
1149 1155
1150 1156 $ echo 'largefile2' > lfs.test
1151 1157 $ echo '012345678901234567890a' > nolfs.exclude
1152 1158 $ echo '01234567890123456a' > lfs.catchall
1153 1159 $ hg ci -Aqm 'after adding .hglfs'
1154 1160 $ hg log -r . -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}\n'
1155 1161 3: lfs.catchall: 31f43b9c62b540126b0ad5884dc013d21a61c9329b77de1fceeae2fc58511573
1156 1162 lfs.test: 8acd23467967bc7b8cc5a280056589b0ba0b17ff21dbd88a7b6474d6290378a6
1157 1163
1158 1164 The LFS policy stops when the .hglfs is gone
1159 1165
1160 1166 $ mv .hglfs .hglfs_
1161 1167 $ echo 'largefile3' > lfs.test
1162 1168 $ echo '012345678901234567890abc' > nolfs.exclude
1163 1169 $ echo '01234567890123456abc' > lfs.catchall
1164 1170 $ hg ci -qm 'file test' -X .hglfs
1165 1171 $ hg log -r . -T '{rev}: {lfs_files % "{file}: {lfsoid}\n"}\n'
1166 1172 4:
1167 1173
1168 1174 $ mv .hglfs_ .hglfs
1169 1175 $ echo '012345678901234567890abc' > lfs.test
1170 1176 $ hg ci -m 'back to lfs'
1171 1177 $ hg rm lfs.test
1172 1178 $ hg ci -qm 'remove lfs'
1173 1179
1174 1180 {lfs_files} will list deleted files too
1175 1181
1176 1182 $ hg log -T "{lfs_files % '{rev} {file}: {lfspointer.oid}\n'}"
1177 1183 6 lfs.test:
1178 1184 5 lfs.test: sha256:43f8f41171b6f62a6b61ba4ce98a8a6c1649240a47ebafd43120aa215ac9e7f6
1179 1185 3 lfs.catchall: sha256:31f43b9c62b540126b0ad5884dc013d21a61c9329b77de1fceeae2fc58511573
1180 1186 3 lfs.test: sha256:8acd23467967bc7b8cc5a280056589b0ba0b17ff21dbd88a7b6474d6290378a6
1181 1187 2 lfs.catchall: sha256:d4ec46c2869ba22eceb42a729377432052d9dd75d82fc40390ebaadecee87ee9
1182 1188 2 lfs.test: sha256:5489e6ced8c36a7b267292bde9fd5242a5f80a7482e8f23fa0477393dfaa4d6c
1183 1189
1184 1190 $ hg log -r 'file("set:lfs()")' -T '{rev} {join(lfs_files, ", ")}\n'
1185 1191 2 lfs.catchall, lfs.test
1186 1192 3 lfs.catchall, lfs.test
1187 1193 5 lfs.test
1188 1194 6 lfs.test
1189 1195
1190 1196 $ cd ..
1191 1197
1192 1198 Unbundling adds a requirement to a non-lfs repo, if necessary.
1193 1199
1194 1200 $ hg bundle -R $TESTTMP/repo-del -qr 0 --base null nolfs.hg
1195 1201 $ hg bundle -R convert_lfs2 -qr tip --base null lfs.hg
1196 1202 $ hg init unbundle
1197 1203 $ hg pull -R unbundle -q nolfs.hg
1198 1204 $ grep lfs unbundle/.hg/requires
1199 1205 [1]
1200 1206 $ hg pull -R unbundle -q lfs.hg
1201 1207 $ grep lfs unbundle/.hg/requires
1202 1208 lfs
1203 1209
1204 1210 $ hg init no_lfs
1205 1211 $ cat >> no_lfs/.hg/hgrc <<EOF
1206 1212 > [experimental]
1207 1213 > changegroup3 = True
1208 1214 > [extensions]
1209 1215 > lfs=!
1210 1216 > EOF
1211 1217 $ cp -R no_lfs no_lfs2
1212 1218
1213 1219 Pushing from a local lfs repo to a local repo without an lfs requirement and
1214 1220 with lfs disabled, fails.
1215 1221
1216 1222 $ hg push -R convert_lfs2 no_lfs
1217 1223 pushing to no_lfs
1218 1224 abort: required features are not supported in the destination: lfs
1219 1225 [255]
1220 1226 $ grep lfs no_lfs/.hg/requires
1221 1227 [1]
1222 1228
1223 1229 Pulling from a local lfs repo to a local repo without an lfs requirement and
1224 1230 with lfs disabled, fails.
1225 1231
1226 1232 $ hg pull -R no_lfs2 convert_lfs2
1227 1233 pulling from convert_lfs2
1228 1234 abort: required features are not supported in the destination: lfs
1229 1235 [255]
1230 1236 $ grep lfs no_lfs2/.hg/requires
1231 1237 [1]
General Comments 0
You need to be logged in to leave comments. Login now