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