##// END OF EJS Templates
revlog: add some direct testing of the slicing logic...
Boris Feld -
r41063:cca12a31 default
parent child Browse files
Show More
@@ -12,11 +12,16 b' from mercurial import ('
12 vfs,
12 vfs,
13 )
13 )
14
14
15 from mercurial.revlogutils import (
16 deltas,
17 )
18
15 # TESTTMP is optional. This makes it convenient to run without run-tests.py
19 # TESTTMP is optional. This makes it convenient to run without run-tests.py
16 tvfs = vfs.vfs(encoding.environ.get(b'TESTTMP', b'/tmp'))
20 tvfs = vfs.vfs(encoding.environ.get(b'TESTTMP', b'/tmp'))
17
21
18 # Enable generaldelta otherwise revlog won't use delta as expected by the test
22 # Enable generaldelta otherwise revlog won't use delta as expected by the test
19 tvfs.options = {b'generaldelta': True, b'revlogv1': True}
23 tvfs.options = {b'generaldelta': True, b'revlogv1': True,
24 b'sparse-revlog': True}
20
25
21 # The test wants to control whether to use delta explicitly, based on
26 # The test wants to control whether to use delta explicitly, based on
22 # "storedeltachains".
27 # "storedeltachains".
@@ -291,6 +296,37 b' def checkrevlog(rlog, expected):'
291 abort('rev %d: corrupted %stext'
296 abort('rev %d: corrupted %stext'
292 % (rev, raw and 'raw' or ''))
297 % (rev, raw and 'raw' or ''))
293
298
299 slicingdata = [
300 ([0, 1, 2, 3, 55, 56, 58, 59, 60],
301 [[0, 1], [2], [58], [59, 60]],
302 10),
303 ([0, 1, 2, 3, 55, 56, 58, 59, 60],
304 [[0, 1], [2], [58], [59, 60]],
305 10),
306 ([-1, 0, 1, 2, 3, 55, 56, 58, 59, 60],
307 [[-1, 0, 1], [2], [58], [59, 60]],
308 10),
309 ]
310
311 def slicingtest(rlog):
312 oldmin = rlog._srmingapsize
313 try:
314 # the test revlog is small, we remove the floor under which we
315 # slicing is diregarded.
316 rlog._srmingapsize = 0
317 for item in slicingdata:
318 chain, expected, target = item
319 result = deltas.slicechunk(rlog, chain, targetsize=target)
320 result = list(result)
321 if result != expected:
322 print('slicing differ:')
323 print(' chain: %s' % chain)
324 print(' target: %s' % target)
325 print(' expected: %s' % expected)
326 print(' result: %s' % result)
327 finally:
328 rlog._srmingapsize = oldmin
329
294 def maintest():
330 def maintest():
295 expected = rl = None
331 expected = rl = None
296 with newtransaction() as tr:
332 with newtransaction() as tr:
@@ -313,6 +349,8 b' def maintest():'
313 rl4 = lowlevelcopy(rl, tr)
349 rl4 = lowlevelcopy(rl, tr)
314 checkrevlog(rl4, expected)
350 checkrevlog(rl4, expected)
315 print('lowlevelcopy test passed')
351 print('lowlevelcopy test passed')
352 slicingtest(rl)
353 print('slicing test passed')
316
354
317 try:
355 try:
318 maintest()
356 maintest()
@@ -2,3 +2,4 b' local test passed'
2 addgroupcopy test passed
2 addgroupcopy test passed
3 clone test passed
3 clone test passed
4 lowlevelcopy test passed
4 lowlevelcopy test passed
5 slicing test passed
General Comments 0
You need to be logged in to leave comments. Login now