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