Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 38638:740f7d447222
revlog: add a doctest to _trimchunk
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Tue, 10 Jul 2018 10:04:44 +0200 |
parents | e33f784f2a44 |
children | 2dd4cf273804 |
comparison
equal
deleted
inserted
replaced
38637:e33f784f2a44 | 38638:740f7d447222 |
---|---|
216 def length(self, rev): | 216 def length(self, rev): |
217 return self.end(rev) - self.start(rev) | 217 return self.end(rev) - self.start(rev) |
218 | 218 |
219 def _trimchunk(revlog, revs, startidx, endidx=None): | 219 def _trimchunk(revlog, revs, startidx, endidx=None): |
220 """returns revs[startidx:endidx] without empty trailing revs | 220 """returns revs[startidx:endidx] without empty trailing revs |
221 | |
222 Doctest Setup | |
223 >>> revlog = _testrevlog([ | |
224 ... 5, #0 | |
225 ... 10, #1 | |
226 ... 12, #2 | |
227 ... 12, #3 (empty) | |
228 ... 17, #4 | |
229 ... 21, #5 | |
230 ... 21, #6 (empty) | |
231 ... ]) | |
232 | |
233 Contiguous cases: | |
234 >>> _trimchunk(revlog, [0, 1, 2, 3, 4, 5, 6], 0) | |
235 [0, 1, 2, 3, 4, 5] | |
236 >>> _trimchunk(revlog, [0, 1, 2, 3, 4, 5, 6], 0, 5) | |
237 [0, 1, 2, 3, 4] | |
238 >>> _trimchunk(revlog, [0, 1, 2, 3, 4, 5, 6], 0, 4) | |
239 [0, 1, 2] | |
240 >>> _trimchunk(revlog, [0, 1, 2, 3, 4, 5, 6], 2, 4) | |
241 [2] | |
242 >>> _trimchunk(revlog, [0, 1, 2, 3, 4, 5, 6], 3) | |
243 [3, 4, 5] | |
244 >>> _trimchunk(revlog, [0, 1, 2, 3, 4, 5, 6], 3, 5) | |
245 [3, 4] | |
246 | |
247 Discontiguous cases: | |
248 >>> _trimchunk(revlog, [1, 3, 5, 6], 0) | |
249 [1, 3, 5] | |
250 >>> _trimchunk(revlog, [1, 3, 5, 6], 0, 2) | |
251 [1] | |
252 >>> _trimchunk(revlog, [1, 3, 5, 6], 1, 3) | |
253 [3, 5] | |
254 >>> _trimchunk(revlog, [1, 3, 5, 6], 1) | |
255 [3, 5] | |
221 """ | 256 """ |
222 length = revlog.length | 257 length = revlog.length |
223 | 258 |
224 if endidx is None: | 259 if endidx is None: |
225 endidx = len(revs) | 260 endidx = len(revs) |