Show More
@@ -59,7 +59,7 b' class _testrevlog(object):' | |||
|
59 | 59 | def __len__(self): |
|
60 | 60 | return len(self._data) |
|
61 | 61 | |
|
62 |
def slicechunk(revlog, revs, |
|
|
62 | def slicechunk(revlog, revs, targetsize=None): | |
|
63 | 63 | """slice revs to reduce the amount of unrelated data to be read from disk. |
|
64 | 64 | |
|
65 | 65 | ``revs`` is sliced into groups that should be read in one time. |
@@ -116,12 +116,7 b' def slicechunk(revlog, revs, deltainfo=N' | |||
|
116 | 116 | targetsize = max(targetsize, revlog._srmingapsize) |
|
117 | 117 | # targetsize should not be specified when evaluating delta candidates: |
|
118 | 118 | # * targetsize is used to ensure we stay within specification when reading, |
|
119 | # * deltainfo is used to pick are good delta chain when writing. | |
|
120 | if not (deltainfo is None or targetsize is None): | |
|
121 | msg = 'cannot use `targetsize` with a `deltainfo`' | |
|
122 | raise error.ProgrammingError(msg) | |
|
123 | 119 | for chunk in _slicechunktodensity(revlog, revs, |
|
124 | deltainfo, | |
|
125 | 120 | revlog._srdensitythreshold, |
|
126 | 121 | revlog._srmingapsize): |
|
127 | 122 | for subchunk in _slicechunktosize(revlog, chunk, targetsize): |
@@ -204,16 +199,13 b' def _slicechunktosize(revlog, revs, targ' | |||
|
204 | 199 | endrevidx = idx |
|
205 | 200 | yield _trimchunk(revlog, revs, startrevidx) |
|
206 | 201 | |
|
207 |
def _slicechunktodensity(revlog, revs, |
|
|
202 | def _slicechunktodensity(revlog, revs, targetdensity=0.5, | |
|
208 | 203 | mingapsize=0): |
|
209 | 204 | """slice revs to reduce the amount of unrelated data to be read from disk. |
|
210 | 205 | |
|
211 | 206 | ``revs`` is sliced into groups that should be read in one time. |
|
212 | 207 | Assume that revs are sorted. |
|
213 | 208 | |
|
214 | ``deltainfo`` is a _deltainfo instance of a revision that we would append | |
|
215 | to the top of the revlog. | |
|
216 | ||
|
217 | 209 | The initial chunk is sliced until the overall density (payload/chunks-span |
|
218 | 210 | ratio) is above `targetdensity`. No gap smaller than `mingapsize` is |
|
219 | 211 | skipped. |
@@ -264,15 +256,8 b' def _slicechunktodensity(revlog, revs, d' | |||
|
264 | 256 | yield revs |
|
265 | 257 | return |
|
266 | 258 | |
|
267 | nextrev = len(revlog) | |
|
268 | nextoffset = revlog.end(nextrev - 1) | |
|
269 | ||
|
270 | if deltainfo is None: | |
|
271 | 259 |
|
|
272 | 260 |
|
|
273 | else: | |
|
274 | deltachainspan = deltainfo.distance | |
|
275 | chainpayload = deltainfo.compresseddeltalen | |
|
276 | 261 | |
|
277 | 262 | if deltachainspan < mingapsize: |
|
278 | 263 | yield revs |
@@ -289,21 +274,13 b' def _slicechunktodensity(revlog, revs, d' | |||
|
289 | 274 | yield revs |
|
290 | 275 | return |
|
291 | 276 | |
|
292 | if deltainfo is not None and deltainfo.deltalen: | |
|
293 | revs = list(revs) | |
|
294 | revs.append(nextrev) | |
|
295 | ||
|
296 | 277 | # Store the gaps in a heap to have them sorted by decreasing size |
|
297 | 278 | gapsheap = [] |
|
298 | 279 | heapq.heapify(gapsheap) |
|
299 | 280 | prevend = None |
|
300 | 281 | for i, rev in enumerate(revs): |
|
301 | if rev < nextrev: | |
|
302 | 282 |
|
|
303 | 283 |
|
|
304 | else: | |
|
305 | revstart = nextoffset | |
|
306 | revlen = deltainfo.deltalen | |
|
307 | 284 | |
|
308 | 285 | # Skip empty revisions to form larger holes |
|
309 | 286 | if revlen == 0: |
General Comments 0
You need to be logged in to leave comments.
Login now