Debian Codegraph @

tests/test-bundle2-remote-changegroup.t

raw
1 Create an extension to test bundle2 remote-changegroup parts
2
3 $ cat > bundle2.py << EOF
4 > """A small extension to test bundle2 remote-changegroup parts.
5 >
6 > Current bundle2 implementation doesn't provide a way to generate those
7 > parts, so they must be created by extensions.
8 > """
9 > from mercurial import (
10 > bundle2,
11 > changegroup,
12 > discovery,
13 > exchange,
14 > pycompat,
15 > util,
16 > )
17 >
18 > def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None,
19 > b2caps=None, heads=None, common=None,
20 > **kwargs):
21 > """this function replaces the changegroup part handler for getbundle.
22 > It allows to create a set of arbitrary parts containing changegroups
23 > and remote-changegroups, as described in a bundle2maker file in the
24 > repository .hg/ directory.
25 >
26 > Each line of that bundle2maker file contain a description of the
27 > part to add:
28 > - changegroup common_revset heads_revset
29 > Creates a changegroup part based, using common_revset and
30 > heads_revset for outgoing
31 > - remote-changegroup url file
32 > Creates a remote-changegroup part for a bundle at the given
33 > url. Size and digest, as required by the client, are computed
34 > from the given file.
35 > - raw-remote-changegroup <python expression>
36 > Creates a remote-changegroup part with the data given in the
37 > Python expression as parameters. The Python expression is
38 > evaluated with eval, and is expected to be a dict.
39 > """
40 > def newpart(name, data=b''):
41 > """wrapper around bundler.newpart adding an extra part making the
42 > client output information about each processed part"""
43 > bundler.newpart(b'output', data=name)
44 > part = bundler.newpart(name, data=data)
45 > return part
46 >
47 > for line in open(repo.vfs.join(b'bundle2maker'), 'rb'):
48 > line = line.strip()
49 > try:
50 > verb, args = line.split(None, 1)
51 > except ValueError:
52 > verb, args = line, b''
53 > if verb == b'remote-changegroup':
54 > url, file = args.split()
55 > bundledata = open(file, 'rb').read()
56 > digest = util.digester.preferred(b2caps[b'digests'])
57 > d = util.digester([digest], bundledata)
58 > part = newpart(b'remote-changegroup')
59 > part.addparam(b'url', url)
60 > part.addparam(b'size', b'%d' % len(bundledata))
61 > part.addparam(b'digests', digest)
62 > part.addparam(b'digest:%s' % digest, d[digest])
63 > elif verb == b'raw-remote-changegroup':
64 > part = newpart(b'remote-changegroup')
65 > for k, v in eval(args).items():
66 > part.addparam(pycompat.sysbytes(k), pycompat.bytestr(v))
67 > elif verb == b'changegroup':
68 > _common, heads = args.split()
69 > common.extend(repo[r].node() for r in repo.revs(_common))
70 > heads = [repo[r].node() for r in repo.revs(heads)]
71 > outgoing = discovery.outgoing(repo, common, heads)
72 > cg = changegroup.makechangegroup(repo, outgoing, b'01',
73 > b'changegroup')
74 > newpart(b'changegroup', cg.getchunks())
75 > else:
76 > raise Exception('unknown verb')
77 >
78 > exchange.getbundle2partsmapping[b'changegroup'] = _getbundlechangegrouppart
79 > EOF
80
81 Start a simple HTTP server to serve bundles
82
83 $ "$PYTHON" "$TESTDIR/dumbhttp.py" -p $HGPORT --pid dumb.pid
84 $ cat dumb.pid >> $DAEMON_PIDS
85
86 $ cat >> $HGRCPATH << EOF
87 > [command-templates]
88 > log={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
89 > EOF
90
91 $ hg init repo
92
93 $ hg -R repo unbundle $TESTDIR/bundles/rebase.hg
94 adding changesets
95 adding manifests
96 adding file changes
97 added 8 changesets with 7 changes to 7 files (+2 heads)
98 new changesets cd010b8cd998:02de42196ebe (8 drafts)
99 (run 'hg heads' to see heads, 'hg merge' to merge)
100
101 $ hg -R repo log -G
102 o 7:02de42196ebe draft Nicolas Dumazet <[email protected]> H
103 |
104 | o 6:eea13746799a draft Nicolas Dumazet <[email protected]> G
105 |/|
106 o | 5:24b6387c8c8c draft Nicolas Dumazet <[email protected]> F
107 | |
108 | o 4:9520eea781bc draft Nicolas Dumazet <[email protected]> E
109 |/
110 | o 3:32af7686d403 draft Nicolas Dumazet <[email protected]> D
111 | |
112 | o 2:5fddd98957c8 draft Nicolas Dumazet <[email protected]> C
113 | |
114 | o 1:42ccdea3bb16 draft Nicolas Dumazet <[email protected]> B
115 |/
116 o 0:cd010b8cd998 draft Nicolas Dumazet <[email protected]> A
117
118 $ hg clone repo orig
119 updating to branch default
120 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
121
122 $ cat > repo/.hg/hgrc << EOF
123 > [extensions]
124 > bundle2=$TESTTMP/bundle2.py
125 > EOF
126
127 Test a pull with an remote-changegroup
128
129 $ hg bundle -R repo --type v1 --base '0:4' -r '5:7' bundle.hg
130 3 changesets found
131 $ cat > repo/.hg/bundle2maker << EOF
132 > remote-changegroup http://localhost:$HGPORT/bundle.hg bundle.hg
133 > EOF
134 $ hg clone orig clone -r 3 -r 4
135 adding changesets
136 adding manifests
137 adding file changes
138 added 5 changesets with 5 changes to 5 files (+1 heads)
139 new changesets cd010b8cd998:9520eea781bc
140 updating to branch default
141 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
142 $ hg pull -R clone ssh://user@dummy/repo
143 pulling from ssh://user@dummy/repo
144 searching for changes
145 remote: remote-changegroup
146 adding changesets
147 adding manifests
148 adding file changes
149 added 3 changesets with 2 changes to 2 files (+1 heads)
150 new changesets 24b6387c8c8c:02de42196ebe
151 (run 'hg heads .' to see heads, 'hg merge' to merge)
152 $ hg -R clone log -G
153 o 7:02de42196ebe public Nicolas Dumazet <[email protected]> H
154 |
155 | o 6:eea13746799a public Nicolas Dumazet <[email protected]> G
156 |/|
157 o | 5:24b6387c8c8c public Nicolas Dumazet <[email protected]> F
158 | |
159 | o 4:9520eea781bc public Nicolas Dumazet <[email protected]> E
160 |/
161 | @ 3:32af7686d403 public Nicolas Dumazet <[email protected]> D
162 | |
163 | o 2:5fddd98957c8 public Nicolas Dumazet <[email protected]> C
164 | |
165 | o 1:42ccdea3bb16 public Nicolas Dumazet <[email protected]> B
166 |/
167 o 0:cd010b8cd998 public Nicolas Dumazet <[email protected]> A
168
169 $ rm -rf clone
170
171 Test a pull with an remote-changegroup and a following changegroup
172
173 $ hg bundle -R repo --type v1 --base 2 -r '3:4' bundle2.hg
174 2 changesets found
175 $ cat > repo/.hg/bundle2maker << EOF
176 > remote-changegroup http://localhost:$HGPORT/bundle2.hg bundle2.hg
177 > changegroup 0:4 5:7
178 > EOF
179 $ hg clone orig clone -r 2
180 adding changesets
181 adding manifests
182 adding file changes
183 added 3 changesets with 3 changes to 3 files
184 new changesets cd010b8cd998:5fddd98957c8
185 updating to branch default
186 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
187 $ hg pull -R clone ssh://user@dummy/repo
188 pulling from ssh://user@dummy/repo
189 searching for changes
190 remote: remote-changegroup
191 adding changesets
192 adding manifests
193 adding file changes
194 remote: changegroup
195 adding changesets
196 adding manifests
197 adding file changes
198 added 5 changesets with 4 changes to 4 files (+2 heads)
199 new changesets 32af7686d403:02de42196ebe
200 (run 'hg heads' to see heads, 'hg merge' to merge)
201 $ hg -R clone log -G
202 o 7:02de42196ebe public Nicolas Dumazet <[email protected]> H
203 |
204 | o 6:eea13746799a public Nicolas Dumazet <[email protected]> G
205 |/|
206 o | 5:24b6387c8c8c public Nicolas Dumazet <[email protected]> F
207 | |
208 | o 4:9520eea781bc public Nicolas Dumazet <[email protected]> E
209 |/
210 | o 3:32af7686d403 public Nicolas Dumazet <[email protected]> D
211 | |
212 | @ 2:5fddd98957c8 public Nicolas Dumazet <[email protected]> C
213 | |
214 | o 1:42ccdea3bb16 public Nicolas Dumazet <[email protected]> B
215 |/
216 o 0:cd010b8cd998 public Nicolas Dumazet <[email protected]> A
217
218 $ rm -rf clone
219
220 Test a pull with a changegroup followed by an remote-changegroup
221
222 $ hg bundle -R repo --type v1 --base '0:4' -r '5:7' bundle3.hg
223 3 changesets found
224 $ cat > repo/.hg/bundle2maker << EOF
225 > changegroup 000000000000 :4
226 > remote-changegroup http://localhost:$HGPORT/bundle3.hg bundle3.hg
227 > EOF
228 $ hg clone orig clone -r 2
229 adding changesets
230 adding manifests
231 adding file changes
232 added 3 changesets with 3 changes to 3 files
233 new changesets cd010b8cd998:5fddd98957c8
234 updating to branch default
235 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
236 $ hg pull -R clone ssh://user@dummy/repo
237 pulling from ssh://user@dummy/repo
238 searching for changes
239 remote: changegroup
240 adding changesets
241 adding manifests
242 adding file changes
243 remote: remote-changegroup
244 adding changesets
245 adding manifests
246 adding file changes
247 added 5 changesets with 4 changes to 4 files (+2 heads)
248 new changesets 32af7686d403:02de42196ebe
249 (run 'hg heads' to see heads, 'hg merge' to merge)
250 $ hg -R clone log -G
251 o 7:02de42196ebe public Nicolas Dumazet <[email protected]> H
252 |
253 | o 6:eea13746799a public Nicolas Dumazet <[email protected]> G
254 |/|
255 o | 5:24b6387c8c8c public Nicolas Dumazet <[email protected]> F
256 | |
257 | o 4:9520eea781bc public Nicolas Dumazet <[email protected]> E
258 |/
259 | o 3:32af7686d403 public Nicolas Dumazet <[email protected]> D
260 | |
261 | @ 2:5fddd98957c8 public Nicolas Dumazet <[email protected]> C
262 | |
263 | o 1:42ccdea3bb16 public Nicolas Dumazet <[email protected]> B
264 |/
265 o 0:cd010b8cd998 public Nicolas Dumazet <[email protected]> A
266
267 $ rm -rf clone
268
269 Test a pull with two remote-changegroups and a changegroup
270
271 $ hg bundle -R repo --type v1 --base 2 -r '3:4' bundle4.hg
272 2 changesets found
273 $ hg bundle -R repo --type v1 --base '3:4' -r '5:6' bundle5.hg
274 2 changesets found
275 $ cat > repo/.hg/bundle2maker << EOF
276 > remote-changegroup http://localhost:$HGPORT/bundle4.hg bundle4.hg
277 > remote-changegroup http://localhost:$HGPORT/bundle5.hg bundle5.hg
278 > changegroup 0:6 7
279 > EOF
280 $ hg clone orig clone -r 2
281 adding changesets
282 adding manifests
283 adding file changes
284 added 3 changesets with 3 changes to 3 files
285 new changesets cd010b8cd998:5fddd98957c8
286 updating to branch default
287 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
288 $ hg pull -R clone ssh://user@dummy/repo
289 pulling from ssh://user@dummy/repo
290 searching for changes
291 remote: remote-changegroup
292 adding changesets
293 adding manifests
294 adding file changes
295 remote: remote-changegroup
296 adding changesets
297 adding manifests
298 adding file changes
299 remote: changegroup
300 adding changesets
301 adding manifests
302 adding file changes
303 added 5 changesets with 4 changes to 4 files (+2 heads)
304 new changesets 32af7686d403:02de42196ebe
305 (run 'hg heads' to see heads, 'hg merge' to merge)
306 $ hg -R clone log -G
307 o 7:02de42196ebe public Nicolas Dumazet <[email protected]> H
308 |
309 | o 6:eea13746799a public Nicolas Dumazet <[email protected]> G
310 |/|
311 o | 5:24b6387c8c8c public Nicolas Dumazet <[email protected]> F
312 | |
313 | o 4:9520eea781bc public Nicolas Dumazet <[email protected]> E
314 |/
315 | o 3:32af7686d403 public Nicolas Dumazet <[email protected]> D
316 | |
317 | @ 2:5fddd98957c8 public Nicolas Dumazet <[email protected]> C
318 | |
319 | o 1:42ccdea3bb16 public Nicolas Dumazet <[email protected]> B
320 |/
321 o 0:cd010b8cd998 public Nicolas Dumazet <[email protected]> A
322
323 $ rm -rf clone
324
325 Hash digest tests
326
327 $ hg bundle -R repo --type v1 -a bundle6.hg
328 8 changesets found
329
330 $ cat > repo/.hg/bundle2maker << EOF
331 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'sha1', 'digest:sha1': '2c880cfec23cff7d8f80c2f12958d1563cbdaba6'}
332 > EOF
333 $ hg clone ssh://user@dummy/repo clone
334 requesting all changes
335 remote: remote-changegroup
336 adding changesets
337 adding manifests
338 adding file changes
339 added 8 changesets with 7 changes to 7 files (+2 heads)
340 new changesets cd010b8cd998:02de42196ebe
341 updating to branch default
342 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
343 $ rm -rf clone
344
345 $ cat > repo/.hg/bundle2maker << EOF
346 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'md5', 'digest:md5': 'e22172c2907ef88794b7bea6642c2394'}
347 > EOF
348 $ hg clone ssh://user@dummy/repo clone
349 requesting all changes
350 remote: remote-changegroup
351 adding changesets
352 adding manifests
353 adding file changes
354 added 8 changesets with 7 changes to 7 files (+2 heads)
355 new changesets cd010b8cd998:02de42196ebe
356 updating to branch default
357 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
358 $ rm -rf clone
359
360 Hash digest mismatch throws an error
361
362 $ cat > repo/.hg/bundle2maker << EOF
363 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'sha1', 'digest:sha1': '0' * 40}
364 > EOF
365 $ hg clone ssh://user@dummy/repo clone
366 requesting all changes
367 remote: remote-changegroup
368 adding changesets
369 adding manifests
370 adding file changes
371 transaction abort!
372 rollback completed
373 abort: bundle at http://localhost:$HGPORT/bundle6.hg is corrupted:
374 sha1 mismatch: expected 0000000000000000000000000000000000000000, got 2c880cfec23cff7d8f80c2f12958d1563cbdaba6
375 [255]
376
377 Multiple hash digests can be given
378
379 $ cat > repo/.hg/bundle2maker << EOF
380 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'md5 sha1', 'digest:md5': 'e22172c2907ef88794b7bea6642c2394', 'digest:sha1': '2c880cfec23cff7d8f80c2f12958d1563cbdaba6'}
381 > EOF
382 $ hg clone ssh://user@dummy/repo clone
383 requesting all changes
384 remote: remote-changegroup
385 adding changesets
386 adding manifests
387 adding file changes
388 added 8 changesets with 7 changes to 7 files (+2 heads)
389 new changesets cd010b8cd998:02de42196ebe
390 updating to branch default
391 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
392 $ rm -rf clone
393
394 If either of the multiple hash digests mismatches, an error is thrown
395
396 $ cat > repo/.hg/bundle2maker << EOF
397 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'md5 sha1', 'digest:md5': '0' * 32, 'digest:sha1': '2c880cfec23cff7d8f80c2f12958d1563cbdaba6'}
398 > EOF
399 $ hg clone ssh://user@dummy/repo clone
400 requesting all changes
401 remote: remote-changegroup
402 adding changesets
403 adding manifests
404 adding file changes
405 transaction abort!
406 rollback completed
407 abort: bundle at http://localhost:$HGPORT/bundle6.hg is corrupted:
408 md5 mismatch: expected 00000000000000000000000000000000, got e22172c2907ef88794b7bea6642c2394
409 [255]
410
411 $ cat > repo/.hg/bundle2maker << EOF
412 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'md5 sha1', 'digest:md5': 'e22172c2907ef88794b7bea6642c2394', 'digest:sha1': '0' * 40}
413 > EOF
414 $ hg clone ssh://user@dummy/repo clone
415 requesting all changes
416 remote: remote-changegroup
417 adding changesets
418 adding manifests
419 adding file changes
420 transaction abort!
421 rollback completed
422 abort: bundle at http://localhost:$HGPORT/bundle6.hg is corrupted:
423 sha1 mismatch: expected 0000000000000000000000000000000000000000, got 2c880cfec23cff7d8f80c2f12958d1563cbdaba6
424 [255]
425
426 Corruption tests
427
428 $ hg clone orig clone -r 2
429 adding changesets
430 adding manifests
431 adding file changes
432 added 3 changesets with 3 changes to 3 files
433 new changesets cd010b8cd998:5fddd98957c8
434 updating to branch default
435 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
436
437 $ cat > repo/.hg/bundle2maker << EOF
438 > remote-changegroup http://localhost:$HGPORT/bundle4.hg bundle4.hg
439 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle5.hg', 'size': 578, 'digests': 'sha1', 'digest:sha1': '0' * 40}
440 > changegroup 0:6 7
441 > EOF
442 $ hg pull -R clone ssh://user@dummy/repo
443 pulling from ssh://user@dummy/repo
444 searching for changes
445 remote: remote-changegroup
446 adding changesets
447 adding manifests
448 adding file changes
449 remote: remote-changegroup
450 adding changesets
451 adding manifests
452 adding file changes
453 transaction abort!
454 rollback completed
455 abort: bundle at http://localhost:$HGPORT/bundle5.hg is corrupted:
456 sha1 mismatch: expected 0000000000000000000000000000000000000000, got f29485d6bfd37db99983cfc95ecb52f8ca396106
457 [255]
458
459 The entire transaction has been rolled back in the pull above
460
461 $ hg -R clone log -G
462 @ 2:5fddd98957c8 public Nicolas Dumazet <[email protected]> C
463 |
464 o 1:42ccdea3bb16 public Nicolas Dumazet <[email protected]> B
465 |
466 o 0:cd010b8cd998 public Nicolas Dumazet <[email protected]> A
467
468
469 No params
470
471 $ cat > repo/.hg/bundle2maker << EOF
472 > raw-remote-changegroup {}
473 > EOF
474 $ hg pull -R clone ssh://user@dummy/repo
475 pulling from ssh://user@dummy/repo
476 searching for changes
477 remote: remote-changegroup
478 abort: remote-changegroup: missing "url" param
479 [255]
480
481 Missing size
482
483 $ cat > repo/.hg/bundle2maker << EOF
484 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle4.hg'}
485 > EOF
486 $ hg pull -R clone ssh://user@dummy/repo
487 pulling from ssh://user@dummy/repo
488 searching for changes
489 remote: remote-changegroup
490 abort: remote-changegroup: missing "size" param
491 [255]
492
493 Invalid size
494
495 $ cat > repo/.hg/bundle2maker << EOF
496 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle4.hg', 'size': 'foo'}
497 > EOF
498 $ hg pull -R clone ssh://user@dummy/repo
499 pulling from ssh://user@dummy/repo
500 searching for changes
501 remote: remote-changegroup
502 abort: remote-changegroup: invalid value for param "size"
503 [255]
504
505 Size mismatch
506
507 $ cat > repo/.hg/bundle2maker << EOF
508 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle4.hg', 'size': 42}
509 > EOF
510 $ hg pull -R clone ssh://user@dummy/repo
511 pulling from ssh://user@dummy/repo
512 searching for changes
513 remote: remote-changegroup
514 adding changesets
515 adding manifests
516 adding file changes
517 transaction abort!
518 rollback completed
519 abort: bundle at http://localhost:$HGPORT/bundle4.hg is corrupted:
520 size mismatch: expected 42, got 581
521 [255]
522
523 Unknown digest
524
525 $ cat > repo/.hg/bundle2maker << EOF
526 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle4.hg', 'size': 581, 'digests': 'foo', 'digest:foo': 'bar'}
527 > EOF
528 $ hg pull -R clone ssh://user@dummy/repo
529 pulling from ssh://user@dummy/repo
530 searching for changes
531 remote: remote-changegroup
532 abort: missing support for remote-changegroup - digest:foo
533 [100]
534
535 Missing digest
536
537 $ cat > repo/.hg/bundle2maker << EOF
538 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle4.hg', 'size': 581, 'digests': 'sha1'}
539 > EOF
540 $ hg pull -R clone ssh://user@dummy/repo
541 pulling from ssh://user@dummy/repo
542 searching for changes
543 remote: remote-changegroup
544 abort: remote-changegroup: missing "digest:sha1" param
545 [255]
546
547 Not an HTTP url
548
549 $ cat > repo/.hg/bundle2maker << EOF
550 > raw-remote-changegroup {'url': 'ssh://localhost:$HGPORT/bundle4.hg', 'size': 581}
551 > EOF
552 $ hg pull -R clone ssh://user@dummy/repo
553 pulling from ssh://user@dummy/repo
554 searching for changes
555 remote: remote-changegroup
556 abort: remote-changegroup does not support ssh urls
557 [255]
558
559 Not a bundle
560
561 $ cat > notbundle.hg << EOF
562 > foo
563 > EOF
564 $ cat > repo/.hg/bundle2maker << EOF
565 > remote-changegroup http://localhost:$HGPORT/notbundle.hg notbundle.hg
566 > EOF
567 $ hg pull -R clone ssh://user@dummy/repo
568 pulling from ssh://user@dummy/repo
569 searching for changes
570 remote: remote-changegroup
571 abort: http://localhost:$HGPORT/notbundle.hg: not a Mercurial bundle
572 [255]
573
574 Not a bundle 1.0
575
576 $ cat > notbundle10.hg << EOF
577 > HG20
578 > EOF
579 $ cat > repo/.hg/bundle2maker << EOF
580 > remote-changegroup http://localhost:$HGPORT/notbundle10.hg notbundle10.hg
581 > EOF
582 $ hg pull -R clone ssh://user@dummy/repo
583 pulling from ssh://user@dummy/repo
584 searching for changes
585 remote: remote-changegroup
586 abort: http://localhost:$HGPORT/notbundle10.hg: not a bundle version 1.0
587 [255]
588
589 $ hg -R clone log -G
590 @ 2:5fddd98957c8 public Nicolas Dumazet <[email protected]> C
591 |
592 o 1:42ccdea3bb16 public Nicolas Dumazet <[email protected]> B
593 |
594 o 0:cd010b8cd998 public Nicolas Dumazet <[email protected]> A
595
596 $ rm -rf clone
597
598 $ killdaemons.py