Mercurial > hg
comparison mercurial/revlog.py @ 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 |
comparison
equal
deleted
inserted
replaced
38635:d083ae26c325 | 38636:25534e0cf0d9 |
---|---|
208 while endidx > 1 and endidx > startidx and length(revs[endidx - 1]) == 0: | 208 while endidx > 1 and endidx > startidx and length(revs[endidx - 1]) == 0: |
209 endidx -= 1 | 209 endidx -= 1 |
210 | 210 |
211 return revs[startidx:endidx] | 211 return revs[startidx:endidx] |
212 | 212 |
213 def _segmentspan(revlog, revs): | |
214 """Get the byte span of a segment of revisions | |
215 | |
216 revs is a sorted array of revision numbers | |
217 """ | |
218 if not revs: | |
219 return 0 | |
220 return revlog.end(revs[-1]) - revlog.start(revs[0]) | |
221 | |
213 def _slicechunk(revlog, revs): | 222 def _slicechunk(revlog, revs): |
214 """slice revs to reduce the amount of unrelated data to be read from disk. | 223 """slice revs to reduce the amount of unrelated data to be read from disk. |
215 | 224 |
216 ``revs`` is sliced into groups that should be read in one time. | 225 ``revs`` is sliced into groups that should be read in one time. |
217 Assume that revs are sorted. | 226 Assume that revs are sorted. |
221 | 230 |
222 if len(revs) <= 1: | 231 if len(revs) <= 1: |
223 yield revs | 232 yield revs |
224 return | 233 return |
225 | 234 |
226 startbyte = start(revs[0]) | 235 readdata = deltachainspan = _segmentspan(revlog, revs) |
227 endbyte = start(revs[-1]) + length(revs[-1]) | |
228 readdata = deltachainspan = endbyte - startbyte | |
229 | 236 |
230 if deltachainspan < revlog._srmingapsize: | 237 if deltachainspan < revlog._srmingapsize: |
231 yield revs | 238 yield revs |
232 return | 239 return |
233 | 240 |