# HG changeset patch # User Paul Morelle # Date 1526562636 -7200 # Node ID 25534e0cf0d9f01c24c1d0141c48ce80ae671541 # Parent d083ae26c325d7732594ff262aaa0f1b8eeb7157 revlog: _segmentspan computes the byte span of a segment Refactor out this code to be used somewhere else in a next changeset diff -r d083ae26c325 -r 25534e0cf0d9 mercurial/revlog.py --- 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