comparison mercurial/revlog.py @ 47246:02a4463565ea

revlog: improve documentation of the entry tuple The code in revlog, and outside revlog directly use the index's entry tuple, with direct integer indexing. This is a voluntary trade off to obtains better performance from the Python code at the expense of the developers sanity. Let's at least have a clear and central documentation about what this tuple is about. Differential Revision: https://phab.mercurial-scm.org/D10643
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 03 May 2021 16:52:38 +0200
parents de63be070e02
children 130c9f7ed914
comparison
equal deleted inserted replaced
47245:de63be070e02 47246:02a4463565ea
282 282
283 `concurrencychecker` is an optional function that receives 3 arguments: a 283 `concurrencychecker` is an optional function that receives 3 arguments: a
284 file handle, a filename, and an expected position. It should check whether 284 file handle, a filename, and an expected position. It should check whether
285 the current position in the file handle is valid, and log/warn/fail (by 285 the current position in the file handle is valid, and log/warn/fail (by
286 raising). 286 raising).
287
288
289 Internal details
290 ----------------
291
292 A large part of the revlog logic deals with revisions' "index entries", tuple
293 objects that contains the same "items" whatever the revlog version.
294 Different versions will have different ways of storing these items (sometimes
295 not having them at all), but the tuple will always be the same. New fields
296 are usually added at the end to avoid breaking existing code that relies
297 on the existing order. The field are defined as follows:
298
299 [0] offset:
300 The byte index of the start of revision data chunk.
301 That value is shifted up by 16 bits. use "offset = field >> 16" to
302 retrieve it.
303
304 flags:
305 A flag field that carries special information or changes the behavior
306 of the revision. (see `REVIDX_*` constants for details)
307 The flag field only occupies the first 16 bits of this field,
308 use "flags = field & 0xFFFF" to retrieve the value.
309
310 [1] compressed length:
311 The size, in bytes, of the chunk on disk
312
313 [2] uncompressed length:
314 The size, in bytes, of the full revision once reconstructed.
315
316 [3] base rev:
317 Either the base of the revision delta chain (without general
318 delta), or the base of the delta (stored in the data chunk)
319 with general delta.
320
321 [4] link rev:
322 Changelog revision number of the changeset introducing this
323 revision.
324
325 [5] parent 1 rev:
326 Revision number of the first parent
327
328 [6] parent 2 rev:
329 Revision number of the second parent
330
331 [7] node id:
332 The node id of the current revision
333
334 [8] sidedata offset:
335 The byte index of the start of the revision's side-data chunk.
336
337 [9] sidedata chunk length:
338 The size, in bytes, of the revision's side-data chunk.
287 """ 339 """
288 340
289 _flagserrorclass = error.RevlogError 341 _flagserrorclass = error.RevlogError
290 342
291 def __init__( 343 def __init__(