Mercurial > hg
changeset 38636:25534e0cf0d9
revlog: _segmentspan computes the byte span of a segment
Refactor out this code to be used somewhere else in a next changeset
author | Paul Morelle <paul.morelle@octobus.net> |
---|---|
date | Thu, 17 May 2018 15:10:36 +0200 |
parents | d083ae26c325 |
children | e33f784f2a44 |
files | mercurial/revlog.py |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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