##// END OF EJS Templates
revlog: add an explicit test for `issnapshot`...
Boris Feld -
r41064:15f78383 default
parent child Browse files
Show More
@@ -2,6 +2,7 b''
2
2
3 from __future__ import absolute_import, print_function
3 from __future__ import absolute_import, print_function
4
4
5 import hashlib
5 import sys
6 import sys
6
7
7 from mercurial import (
8 from mercurial import (
@@ -327,6 +328,75 b' def slicingtest(rlog):'
327 finally:
328 finally:
328 rlog._srmingapsize = oldmin
329 rlog._srmingapsize = oldmin
329
330
331 def md5sum(s):
332 return hashlib.md5(s).digest()
333
334 def _maketext(*coord):
335 """create piece of text according to range of integers
336
337 The test returned use a md5sum of the integer to make it less
338 compressible"""
339 pieces = []
340 for start, size in coord:
341 num = range(start, start + size)
342 p = [md5sum(b'%d' % r) for r in num]
343 pieces.append(b'\n'.join(p))
344 return b'\n'.join(pieces) + b'\n'
345
346 data = [
347 _maketext((0, 120), (456, 60)),
348 _maketext((0, 120), (345, 60)),
349 _maketext((0, 120), (734, 60)),
350 _maketext((0, 120), (734, 60), (923, 45)),
351 _maketext((0, 120), (734, 60), (234, 45)),
352 _maketext((0, 120), (734, 60), (564, 45)),
353 _maketext((0, 120), (734, 60), (361, 45)),
354 _maketext((0, 120), (734, 60), (489, 45)),
355 _maketext((0, 120), (123, 60)),
356 _maketext((0, 120), (145, 60)),
357 _maketext((0, 120), (104, 60)),
358 _maketext((0, 120), (430, 60)),
359 _maketext((0, 120), (430, 60), (923, 45)),
360 _maketext((0, 120), (430, 60), (234, 45)),
361 _maketext((0, 120), (430, 60), (564, 45)),
362 _maketext((0, 120), (430, 60), (361, 45)),
363 _maketext((0, 120), (430, 60), (489, 45)),
364 _maketext((0, 120), (249, 60)),
365 _maketext((0, 120), (832, 60)),
366 _maketext((0, 120), (891, 60)),
367 _maketext((0, 120), (543, 60)),
368 _maketext((0, 120), (120, 60)),
369 _maketext((0, 120), (60, 60), (768, 30)),
370 _maketext((0, 120), (60, 60), (260, 30)),
371 _maketext((0, 120), (60, 60), (450, 30)),
372 _maketext((0, 120), (60, 60), (361, 30)),
373 _maketext((0, 120), (60, 60), (886, 30)),
374 _maketext((0, 120), (60, 60), (116, 30)),
375 _maketext((0, 120), (60, 60), (567, 30), (629, 40)),
376 _maketext((0, 120), (60, 60), (569, 30), (745, 40)),
377 _maketext((0, 120), (60, 60), (777, 30), (700, 40)),
378 _maketext((0, 120), (60, 60), (618, 30), (398, 40), (158, 10)),
379 ]
380
381 def makesnapshot(tr):
382 rl = newrevlog(name=b'_snaprevlog3.i', recreate=True)
383 for i in data:
384 appendrev(rl, i, tr)
385 return rl
386
387 snapshots = [-1, 0, 6, 8, 11, 17, 19, 21, 25, 30]
388 def issnapshottest(rlog):
389 result = []
390 if rlog.issnapshot(-1):
391 result.append(-1)
392 for rev in rlog:
393 if rlog.issnapshot(rev):
394 result.append(rev)
395 if snapshots != result:
396 print('snapshot differ:')
397 print(' expected: %s' % snapshots)
398 print(' got: %s' % result)
399
330 def maintest():
400 def maintest():
331 expected = rl = None
401 expected = rl = None
332 with newtransaction() as tr:
402 with newtransaction() as tr:
@@ -351,6 +421,9 b' def maintest():'
351 print('lowlevelcopy test passed')
421 print('lowlevelcopy test passed')
352 slicingtest(rl)
422 slicingtest(rl)
353 print('slicing test passed')
423 print('slicing test passed')
424 rl5 = makesnapshot(tr)
425 issnapshottest(rl5)
426 print('issnapshot test passed')
354
427
355 try:
428 try:
356 maintest()
429 maintest()
@@ -3,3 +3,4 b' addgroupcopy test passed'
3 clone test passed
3 clone test passed
4 lowlevelcopy test passed
4 lowlevelcopy test passed
5 slicing test passed
5 slicing test passed
6 issnapshot test passed
General Comments 0
You need to be logged in to leave comments. Login now