##// END OF EJS Templates
revlog: add a doctest to _trimchunk
Boris Feld -
r38657:740f7d44 default
parent child Browse files
Show More
@@ -218,6 +218,41 b' class _testrevlog(object):'
218 218
219 219 def _trimchunk(revlog, revs, startidx, endidx=None):
220 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 257 length = revlog.length
223 258
@@ -60,6 +60,7 b" testmod('mercurial.patch')"
60 60 testmod('mercurial.pathutil')
61 61 testmod('mercurial.parser')
62 62 testmod('mercurial.pycompat')
63 testmod('mercurial.revlog')
63 64 testmod('mercurial.revsetlang')
64 65 testmod('mercurial.smartset')
65 66 testmod('mercurial.store')
General Comments 0
You need to be logged in to leave comments. Login now