Mercurial > hg
comparison tests/test-revlog-raw.py @ 41087:797a416a91bd
revlog: add test case for _findsnapshots
Testing the method directly is more robust.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 21 Dec 2018 05:27:30 +0100 |
parents | 15f78383d3c8 |
children | 876494fd967d |
comparison
equal
deleted
inserted
replaced
41086:a28833d79aca | 41087:797a416a91bd |
---|---|
1 # test revlog interaction about raw data (flagprocessor) | 1 # test revlog interaction about raw data (flagprocessor) |
2 | 2 |
3 from __future__ import absolute_import, print_function | 3 from __future__ import absolute_import, print_function |
4 | 4 |
5 import collections | |
5 import hashlib | 6 import hashlib |
6 import sys | 7 import sys |
7 | 8 |
8 from mercurial import ( | 9 from mercurial import ( |
9 encoding, | 10 encoding, |
395 if snapshots != result: | 396 if snapshots != result: |
396 print('snapshot differ:') | 397 print('snapshot differ:') |
397 print(' expected: %s' % snapshots) | 398 print(' expected: %s' % snapshots) |
398 print(' got: %s' % result) | 399 print(' got: %s' % result) |
399 | 400 |
401 snapshotmapall = {0: [6, 8, 11, 17, 19, 25], 8: [21], -1: [0, 30]} | |
402 snapshotmap15 = {0: [17, 19, 25], 8: [21], -1: [30]} | |
403 def findsnapshottest(rlog): | |
404 resultall = collections.defaultdict(list) | |
405 deltas._findsnapshots(rlog, resultall, 0) | |
406 resultall = dict(resultall.items()) | |
407 if resultall != snapshotmapall: | |
408 print('snapshot map differ:') | |
409 print(' expected: %s' % snapshotmapall) | |
410 print(' got: %s' % resultall) | |
411 result15 = collections.defaultdict(list) | |
412 deltas._findsnapshots(rlog, result15, 15) | |
413 result15 = dict(result15.items()) | |
414 if result15 != snapshotmap15: | |
415 print('snapshot map differ:') | |
416 print(' expected: %s' % snapshotmap15) | |
417 print(' got: %s' % result15) | |
418 | |
400 def maintest(): | 419 def maintest(): |
401 expected = rl = None | 420 expected = rl = None |
402 with newtransaction() as tr: | 421 with newtransaction() as tr: |
403 rl = newrevlog(recreate=True) | 422 rl = newrevlog(recreate=True) |
404 expected = writecases(rl, tr) | 423 expected = writecases(rl, tr) |
422 slicingtest(rl) | 441 slicingtest(rl) |
423 print('slicing test passed') | 442 print('slicing test passed') |
424 rl5 = makesnapshot(tr) | 443 rl5 = makesnapshot(tr) |
425 issnapshottest(rl5) | 444 issnapshottest(rl5) |
426 print('issnapshot test passed') | 445 print('issnapshot test passed') |
446 findsnapshottest(rl5) | |
447 print('findsnapshot test passed') | |
427 | 448 |
428 try: | 449 try: |
429 maintest() | 450 maintest() |
430 except Exception as ex: | 451 except Exception as ex: |
431 abort('crashed: %s' % ex) | 452 abort('crashed: %s' % ex) |