Mercurial > hg-stable
comparison mercurial/revlog.py @ 38640:f62b8fb0a484
revlog: document and test _slicechunk
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Tue, 10 Jul 2018 10:34:33 +0200 |
parents | 2dd4cf273804 |
children | feba6be0941b |
comparison
equal
deleted
inserted
replaced
38639:2dd4cf273804 | 38640:f62b8fb0a484 |
---|---|
296 def _slicechunk(revlog, revs): | 296 def _slicechunk(revlog, revs): |
297 """slice revs to reduce the amount of unrelated data to be read from disk. | 297 """slice revs to reduce the amount of unrelated data to be read from disk. |
298 | 298 |
299 ``revs`` is sliced into groups that should be read in one time. | 299 ``revs`` is sliced into groups that should be read in one time. |
300 Assume that revs are sorted. | 300 Assume that revs are sorted. |
301 | |
302 The initial chunk is sliced until the overall density (payload/chunks-span | |
303 ratio) is above `revlog._srdensitythreshold`. No gap smaller than | |
304 `revlog._srmingapsize` is skipped. | |
305 | |
306 >>> revlog = _testrevlog([ | |
307 ... 5, #00 (5) | |
308 ... 10, #01 (5) | |
309 ... 12, #02 (2) | |
310 ... 12, #03 (empty) | |
311 ... 27, #04 (15) | |
312 ... 31, #05 (4) | |
313 ... 31, #06 (empty) | |
314 ... 42, #07 (11) | |
315 ... 47, #08 (5) | |
316 ... 47, #09 (empty) | |
317 ... 48, #10 (1) | |
318 ... 51, #11 (3) | |
319 ... 74, #12 (23) | |
320 ... 85, #13 (11) | |
321 ... 86, #14 (1) | |
322 ... 91, #15 (5) | |
323 ... ]) | |
324 | |
325 >>> list(_slicechunk(revlog, range(16))) | |
326 [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]] | |
327 >>> list(_slicechunk(revlog, [0, 15])) | |
328 [[0], [15]] | |
329 >>> list(_slicechunk(revlog, [0, 11, 15])) | |
330 [[0], [11], [15]] | |
331 >>> list(_slicechunk(revlog, [0, 11, 13, 15])) | |
332 [[0], [11, 13, 15]] | |
333 >>> list(_slicechunk(revlog, [1, 2, 3, 5, 8, 10, 11, 14])) | |
334 [[1, 2], [5, 8, 10, 11], [14]] | |
301 """ | 335 """ |
302 start = revlog.start | 336 start = revlog.start |
303 length = revlog.length | 337 length = revlog.length |
304 | 338 |
305 if len(revs) <= 1: | 339 if len(revs) <= 1: |