revlog: _segmentspan computes the byte span of a segment
Refactor out this code to be used somewhere else in a next changeset
--- a/mercurial/revlog.py Tue Jul 10 15:17:05 2018 -0700
+++ b/mercurial/revlog.py Thu May 17 15:10:36 2018 +0200
@@ -210,6 +210,15 @@
return revs[startidx:endidx]
+def _segmentspan(revlog, revs):
+ """Get the byte span of a segment of revisions
+
+ revs is a sorted array of revision numbers
+ """
+ if not revs:
+ return 0
+ return revlog.end(revs[-1]) - revlog.start(revs[0])
+
def _slicechunk(revlog, revs):
"""slice revs to reduce the amount of unrelated data to be read from disk.
@@ -223,9 +232,7 @@
yield revs
return
- startbyte = start(revs[0])
- endbyte = start(revs[-1]) + length(revs[-1])
- readdata = deltachainspan = endbyte - startbyte
+ readdata = deltachainspan = _segmentspan(revlog, revs)
if deltachainspan < revlog._srmingapsize:
yield revs