##// END OF EJS Templates
revlog: move the details of revlog "v1" index inside revlog.utils.constants...
marmoute -
r47616:cc65cea9 default
parent child Browse files
Show More
@@ -17,6 +17,7 b' from .. import ('
17 17 )
18 18
19 19 from ..revlogutils import nodemap as nodemaputil
20 from ..revlogutils import constants as revlog_constants
20 21
21 22 stringio = pycompat.bytesio
22 23
@@ -43,13 +44,13 b' def offset_type(offset, type):'
43 44
44 45 class BaseIndexObject(object):
45 46 # Format of an index entry according to Python's `struct` language
46 index_format = b">Qiiiiii20s12x"
47 index_format = revlog_constants.INDEX_ENTRY_V1.format
47 48 # Size of a C unsigned long long int, platform independent
48 49 big_int_size = struct.calcsize(b'>Q')
49 50 # Size of a C long int, platform independent
50 51 int_size = struct.calcsize(b'>i')
51 52 # Size of the entire index format
52 index_size = struct.calcsize(index_format)
53 index_size = revlog_constants.INDEX_ENTRY_V1.size
53 54 # An empty index entry, used as a default value to be overridden, or nullrev
54 55 null_item = (0, 0, 0, -1, -1, -1, -1, nullid)
55 56
@@ -42,6 +42,7 b' from .revlogutils.constants import ('
42 42 FLAG_GENERALDELTA,
43 43 FLAG_INLINE_DATA,
44 44 INDEX_ENTRY_V0,
45 INDEX_ENTRY_V1,
45 46 REVLOGV0,
46 47 REVLOGV1,
47 48 REVLOGV1_FLAGS,
@@ -326,18 +327,6 b' class revlogoldio(object):'
326 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 330 versionformat = struct.Struct(b">I")
342 331 versionformat_pack = versionformat.pack
343 332 versionformat_unpack = versionformat.unpack
@@ -349,7 +338,7 b' versionformat_unpack = versionformat.unp'
349 338
350 339 class revlogio(object):
351 340 def __init__(self):
352 self.size = indexformatng.size
341 self.size = INDEX_ENTRY_V1.size
353 342
354 343 def parseindex(self, data, inline):
355 344 # call the C implementation to parse the index data
@@ -357,7 +346,7 b' class revlogio(object):'
357 346 return index, cache
358 347
359 348 def packentry(self, entry, node, version, rev):
360 p = indexformatng_pack(*entry)
349 p = INDEX_ENTRY_V1.pack(*entry)
361 350 if rev == 0:
362 351 p = versionformat_pack(version) + p[4:]
363 352 return p
@@ -44,6 +44,19 b' REVLOGV2_FLAGS = FLAG_INLINE_DATA'
44 44 # 20 bytes: nodeid
45 45 INDEX_ENTRY_V0 = struct.Struct(b">4l20s20s20s")
46 46
47 ## index v1
48 # 6 bytes: offset
49 # 2 bytes: flags
50 # 4 bytes: compressed length
51 # 4 bytes: uncompressed length
52 # 4 bytes: base rev
53 # 4 bytes: link rev
54 # 4 bytes: parent 1 rev
55 # 4 bytes: parent 2 rev
56 # 32 bytes: nodeid
57 INDEX_ENTRY_V1 = struct.Struct(b">Qiiiiii20s12x")
58 assert INDEX_ENTRY_V1.size == 32 * 2
59
47 60 # revlog index flags
48 61
49 62 # For historical reasons, revlog's internal flags were exposed via the
General Comments 0
You need to be logged in to leave comments. Login now