##// END OF EJS Templates
changelogv2: use a dedicated on disk format for changelogv2...
marmoute -
r48044:25ce16bf default
parent child Browse files
Show More
@@ -1344,7 +1344,6 b' coreconfigitem('
1344 1344 # Experimental TODOs:
1345 1345 #
1346 1346 # * Same as for evlogv2 (but for the reduction of the number of files)
1347 # * drop the storage of the base
1348 1347 # * Improvement to investigate
1349 1348 # - storing .hgtags fnode
1350 1349 # - storing `rank` of changesets
@@ -295,6 +295,10 b' def parse_index2(data, inline, revlogv2='
295 295 return cls(data, inline), (0, data)
296 296
297 297
298 def parse_index_cl_v2(data):
299 return IndexChangelogV2(data), None
300
301
298 302 class IndexObject2(IndexObject):
299 303 index_format = revlog_constants.INDEX_ENTRY_V2
300 304
@@ -355,6 +359,26 b' class IndexObject2(IndexObject):'
355 359 raise error.ProgrammingError(msg)
356 360
357 361
362 class IndexChangelogV2(IndexObject2):
363 index_format = revlog_constants.INDEX_ENTRY_CL_V2
364
365 def _unpack_entry(self, rev, data, r=True):
366 items = self.index_format.unpack(data)
367 entry = items[:3] + (rev, rev) + items[3:8]
368 data_comp = items[8] & 3
369 sidedata_comp = (items[8] >> 2) & 3
370 return entry + (data_comp, sidedata_comp)
371
372 def _pack_entry(self, rev, entry):
373 assert entry[3] == rev, entry[3]
374 assert entry[4] == rev, entry[4]
375 data = entry[:3] + entry[5:10]
376 data_comp = entry[10] & 3
377 sidedata_comp = (entry[11] & 3) << 2
378 data += (data_comp | sidedata_comp,)
379 return self.index_format.pack(*data)
380
381
358 382 def parse_index_devel_nodemap(data, inline):
359 383 """like parse_index2, but alway return a PersistentNodeMapIndexObject"""
360 384 return PersistentNodeMapIndexObject(data), None
@@ -227,6 +227,15 b' def parse_index_v2(data, inline):'
227 227 return index, cache
228 228
229 229
230 def parse_index_cl_v2(data, inline):
231 # call the C implementation to parse the index data
232 assert not inline
233 from .pure.parsers import parse_index_cl_v2
234
235 index, cache = parse_index_cl_v2(data)
236 return index, cache
237
238
230 239 if util.safehasattr(parsers, 'parse_index_devel_nodemap'):
231 240
232 241 def parse_index_v1_nodemap(data, inline):
@@ -652,7 +661,7 b' class revlog(object):'
652 661 elif self._format_version == REVLOGV2:
653 662 self._parse_index = parse_index_v2
654 663 elif self._format_version == CHANGELOGV2:
655 self._parse_index = parse_index_v2
664 self._parse_index = parse_index_cl_v2
656 665 elif devel_nodemap:
657 666 self._parse_index = parse_index_v1_nodemap
658 667 elif use_rust_index:
@@ -93,6 +93,20 b' assert INDEX_ENTRY_V1.size == 32 * 2'
93 93 INDEX_ENTRY_V2 = struct.Struct(b">Qiiiiii20s12xQiB19x")
94 94 assert INDEX_ENTRY_V2.size == 32 * 3, INDEX_ENTRY_V2.size
95 95
96 # 6 bytes: offset
97 # 2 bytes: flags
98 # 4 bytes: compressed length
99 # 4 bytes: uncompressed length
100 # 4 bytes: parent 1 rev
101 # 4 bytes: parent 2 rev
102 # 32 bytes: nodeid
103 # 8 bytes: sidedata offset
104 # 4 bytes: sidedata compressed length
105 # 1 bytes: compression mode (2 lower bit are data_compression_mode)
106 # 27 bytes: Padding to align to 96 bytes (see RevlogV2Plan wiki page)
107 INDEX_ENTRY_CL_V2 = struct.Struct(b">Qiiii20s12xQiB27x")
108 assert INDEX_ENTRY_CL_V2.size == 32 * 3, INDEX_ENTRY_V2.size
109
96 110 # revlog index flags
97 111
98 112 # 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