Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 46857:cc65cea90edb
revlog: move the details of revlog "v1" index inside revlog.utils.constants
The revlog module is quite large and this kind of format information would handy
for other module. So let us start to gather this information about the format in
a more appropriate place.
We update various reference to this information to use the new "source of truth"
in the process.
Differential Revision: https://phab.mercurial-scm.org/D10304
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 05 Apr 2021 12:21:01 +0200 |
parents | 34e1fa4b548a |
children | 85e3a630cad9 |
comparison
equal
deleted
inserted
replaced
46856:34e1fa4b548a | 46857:cc65cea90edb |
---|---|
40 from .pycompat import getattr | 40 from .pycompat import getattr |
41 from .revlogutils.constants import ( | 41 from .revlogutils.constants import ( |
42 FLAG_GENERALDELTA, | 42 FLAG_GENERALDELTA, |
43 FLAG_INLINE_DATA, | 43 FLAG_INLINE_DATA, |
44 INDEX_ENTRY_V0, | 44 INDEX_ENTRY_V0, |
45 INDEX_ENTRY_V1, | |
45 REVLOGV0, | 46 REVLOGV0, |
46 REVLOGV1, | 47 REVLOGV1, |
47 REVLOGV1_FLAGS, | 48 REVLOGV1_FLAGS, |
48 REVLOGV2, | 49 REVLOGV2, |
49 REVLOGV2_FLAGS, | 50 REVLOGV2_FLAGS, |
324 entry[7], | 325 entry[7], |
325 ) | 326 ) |
326 return INDEX_ENTRY_V0.pack(*e2) | 327 return INDEX_ENTRY_V0.pack(*e2) |
327 | 328 |
328 | 329 |
329 # index ng: | |
330 # 6 bytes: offset | |
331 # 2 bytes: flags | |
332 # 4 bytes: compressed length | |
333 # 4 bytes: uncompressed length | |
334 # 4 bytes: base rev | |
335 # 4 bytes: link rev | |
336 # 4 bytes: parent 1 rev | |
337 # 4 bytes: parent 2 rev | |
338 # 32 bytes: nodeid | |
339 indexformatng = struct.Struct(b">Qiiiiii20s12x") | |
340 indexformatng_pack = indexformatng.pack | |
341 versionformat = struct.Struct(b">I") | 330 versionformat = struct.Struct(b">I") |
342 versionformat_pack = versionformat.pack | 331 versionformat_pack = versionformat.pack |
343 versionformat_unpack = versionformat.unpack | 332 versionformat_unpack = versionformat.unpack |
344 | 333 |
345 # corresponds to uncompressed length of indexformatng (2 gigs, 4-byte | 334 # corresponds to uncompressed length of indexformatng (2 gigs, 4-byte |
347 _maxentrysize = 0x7FFFFFFF | 336 _maxentrysize = 0x7FFFFFFF |
348 | 337 |
349 | 338 |
350 class revlogio(object): | 339 class revlogio(object): |
351 def __init__(self): | 340 def __init__(self): |
352 self.size = indexformatng.size | 341 self.size = INDEX_ENTRY_V1.size |
353 | 342 |
354 def parseindex(self, data, inline): | 343 def parseindex(self, data, inline): |
355 # call the C implementation to parse the index data | 344 # call the C implementation to parse the index data |
356 index, cache = parsers.parse_index2(data, inline) | 345 index, cache = parsers.parse_index2(data, inline) |
357 return index, cache | 346 return index, cache |
358 | 347 |
359 def packentry(self, entry, node, version, rev): | 348 def packentry(self, entry, node, version, rev): |
360 p = indexformatng_pack(*entry) | 349 p = INDEX_ENTRY_V1.pack(*entry) |
361 if rev == 0: | 350 if rev == 0: |
362 p = versionformat_pack(version) + p[4:] | 351 p = versionformat_pack(version) + p[4:] |
363 return p | 352 return p |
364 | 353 |
365 | 354 |