##// END OF EJS Templates
sparse-revlog: fix delta validity computation...
Boris Feld -
r39179:3730b779 stable
parent child Browse files
Show More
@@ -262,13 +262,17 b' def _trimchunk(revlog, revs, startidx, e'
262 if endidx is None:
262 if endidx is None:
263 endidx = len(revs)
263 endidx = len(revs)
264
264
265 # Trim empty revs at the end, but never the very first revision of a chain
265 # If we have a non-emtpy delta candidate, there are nothing to trim
266 while endidx > 1 and endidx > startidx and length(revs[endidx - 1]) == 0:
266 if revs[endidx - 1] < len(revlog):
267 endidx -= 1
267 # Trim empty revs at the end, except the very first revision of a chain
268 while (endidx > 1
269 and endidx > startidx
270 and length(revs[endidx - 1]) == 0):
271 endidx -= 1
268
272
269 return revs[startidx:endidx]
273 return revs[startidx:endidx]
270
274
271 def _segmentspan(revlog, revs):
275 def _segmentspan(revlog, revs, deltainfo=None):
272 """Get the byte span of a segment of revisions
276 """Get the byte span of a segment of revisions
273
277
274 revs is a sorted array of revision numbers
278 revs is a sorted array of revision numbers
@@ -294,7 +298,14 b' def _segmentspan(revlog, revs):'
294 """
298 """
295 if not revs:
299 if not revs:
296 return 0
300 return 0
297 return revlog.end(revs[-1]) - revlog.start(revs[0])
301 if deltainfo is not None and len(revlog) <= revs[-1]:
302 if len(revs) == 1:
303 return deltainfo.deltalen
304 offset = revlog.end(len(revlog) - 1)
305 end = deltainfo.deltalen + offset
306 else:
307 end = revlog.end(revs[-1])
308 return end - revlog.start(revs[0])
298
309
299 def _slicechunk(revlog, revs, deltainfo=None, targetsize=None):
310 def _slicechunk(revlog, revs, deltainfo=None, targetsize=None):
300 """slice revs to reduce the amount of unrelated data to be read from disk.
311 """slice revs to reduce the amount of unrelated data to be read from disk.
@@ -526,7 +537,7 b' def _slicechunktodensity(revlog, revs, d'
526 yield revs
537 yield revs
527 return
538 return
528
539
529 if deltainfo is not None:
540 if deltainfo is not None and deltainfo.deltalen:
530 revs = list(revs)
541 revs = list(revs)
531 revs.append(nextrev)
542 revs.append(nextrev)
532
543
@@ -2444,7 +2455,8 b' class revlog(object):'
2444 deltachain = []
2455 deltachain = []
2445
2456
2446 chunks = _slicechunk(self, deltachain, deltainfo)
2457 chunks = _slicechunk(self, deltachain, deltainfo)
2447 distance = max(map(lambda revs:_segmentspan(self, revs), chunks))
2458 all_span = [_segmentspan(self, revs, deltainfo) for revs in chunks]
2459 distance = max(all_span)
2448 else:
2460 else:
2449 distance = deltainfo.distance
2461 distance = deltainfo.distance
2450
2462
General Comments 0
You need to be logged in to leave comments. Login now