Show More
@@ -17,6 +17,7 b' from .. import (' | |||||
17 | ) |
|
17 | ) | |
18 |
|
18 | |||
19 | from ..revlogutils import nodemap as nodemaputil |
|
19 | from ..revlogutils import nodemap as nodemaputil | |
|
20 | from ..revlogutils import constants as revlog_constants | |||
20 |
|
21 | |||
21 | stringio = pycompat.bytesio |
|
22 | stringio = pycompat.bytesio | |
22 |
|
23 | |||
@@ -43,13 +44,13 b' def offset_type(offset, type):' | |||||
43 |
|
44 | |||
44 | class BaseIndexObject(object): |
|
45 | class BaseIndexObject(object): | |
45 | # Format of an index entry according to Python's `struct` language |
|
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 | # Size of a C unsigned long long int, platform independent |
|
48 | # Size of a C unsigned long long int, platform independent | |
48 | big_int_size = struct.calcsize(b'>Q') |
|
49 | big_int_size = struct.calcsize(b'>Q') | |
49 | # Size of a C long int, platform independent |
|
50 | # Size of a C long int, platform independent | |
50 | int_size = struct.calcsize(b'>i') |
|
51 | int_size = struct.calcsize(b'>i') | |
51 | # Size of the entire index format |
|
52 | # Size of the entire index format | |
52 | index_size = struct.calcsize(index_format) |
|
53 | index_size = revlog_constants.INDEX_ENTRY_V1.size | |
53 | # An empty index entry, used as a default value to be overridden, or nullrev |
|
54 | # An empty index entry, used as a default value to be overridden, or nullrev | |
54 | null_item = (0, 0, 0, -1, -1, -1, -1, nullid) |
|
55 | null_item = (0, 0, 0, -1, -1, -1, -1, nullid) | |
55 |
|
56 |
@@ -42,6 +42,7 b' 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, | |
@@ -326,18 +327,6 b' class revlogoldio(object):' | |||||
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 | |
@@ -349,7 +338,7 b' versionformat_unpack = versionformat.unp' | |||||
349 |
|
338 | |||
350 | class revlogio(object): |
|
339 | class revlogio(object): | |
351 | def __init__(self): |
|
340 | def __init__(self): | |
352 |
self.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 | |
@@ -357,7 +346,7 b' class revlogio(object):' | |||||
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 = |
|
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 |
@@ -44,6 +44,19 b' REVLOGV2_FLAGS = FLAG_INLINE_DATA' | |||||
44 | # 20 bytes: nodeid |
|
44 | # 20 bytes: nodeid | |
45 | INDEX_ENTRY_V0 = struct.Struct(b">4l20s20s20s") |
|
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 | # revlog index flags |
|
60 | # revlog index flags | |
48 |
|
61 | |||
49 | # For historical reasons, revlog's internal flags were exposed via the |
|
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