##// END OF EJS Templates
revlog: add a way to keep track of older uids in the docket...
marmoute -
r48246:c2526315 default
parent child Browse files
Show More
@@ -91,8 +91,11 if stable_docket_file:
91 91 # | This is mandatory as docket must be compatible with the previous
92 92 # | revlog index header.
93 93 # * 1 bytes: size of index uuid
94 # * 1 bytes: number of outdated index uuid
94 95 # * 1 bytes: size of data uuid
96 # * 1 bytes: number of outdated data uuid
95 97 # * 1 bytes: size of sizedata uuid
98 # * 1 bytes: number of outdated data uuid
96 99 # * 8 bytes: size of index-data
97 100 # * 8 bytes: pending size of index-data
98 101 # * 8 bytes: size of data
@@ -100,7 +103,10 if stable_docket_file:
100 103 # * 8 bytes: pending size of data
101 104 # * 8 bytes: pending size of sidedata
102 105 # * 1 bytes: default compression header
103 S_HEADER = struct.Struct(constants.INDEX_HEADER_FMT + b'BBBLLLLLLc')
106 S_HEADER = struct.Struct(constants.INDEX_HEADER_FMT + b'BBBBBBLLLLLLc')
107 # * 1 bytes: size of index uuid
108 # * 8 bytes: size of file
109 S_OLD_UID = struct.Struct('>BL')
104 110
105 111
106 112 class RevlogDocket(object):
@@ -112,8 +118,11 class RevlogDocket(object):
112 118 use_pending=False,
113 119 version_header=None,
114 120 index_uuid=None,
121 older_index_uuids=(),
115 122 data_uuid=None,
123 older_data_uuids=(),
116 124 sidedata_uuid=None,
125 older_sidedata_uuids=(),
117 126 index_end=0,
118 127 pending_index_end=0,
119 128 data_end=0,
@@ -129,8 +138,14 class RevlogDocket(object):
129 138 self._path = revlog._docket_file
130 139 self._opener = revlog.opener
131 140 self._index_uuid = index_uuid
141 self._older_index_uuids = older_index_uuids
132 142 self._data_uuid = data_uuid
143 self._older_data_uuids = older_data_uuids
133 144 self._sidedata_uuid = sidedata_uuid
145 self._older_sidedata_uuids = older_sidedata_uuids
146 assert not set(older_index_uuids) & set(older_data_uuids)
147 assert not set(older_data_uuids) & set(older_sidedata_uuids)
148 assert not set(older_index_uuids) & set(older_sidedata_uuids)
134 149 # thes asserts should be True as long as we have a single index filename
135 150 assert index_end <= pending_index_end
136 151 assert data_end <= pending_data_end
@@ -239,8 +254,11 class RevlogDocket(object):
239 254 data = (
240 255 self._version_header,
241 256 len(self._index_uuid),
257 len(self._older_index_uuids),
242 258 len(self._data_uuid),
259 len(self._older_data_uuids),
243 260 len(self._sidedata_uuid),
261 len(self._older_sidedata_uuids),
244 262 official_index_end,
245 263 self._index_end,
246 264 official_data_end,
@@ -251,9 +269,24 class RevlogDocket(object):
251 269 )
252 270 s = []
253 271 s.append(S_HEADER.pack(*data))
272
254 273 s.append(self._index_uuid)
274 for u, size in self._older_index_uuids:
275 s.append(S_OLD_UID.pack(len(u), size))
276 for u, size in self._older_index_uuids:
277 s.append(u)
278
255 279 s.append(self._data_uuid)
280 for u, size in self._older_data_uuids:
281 s.append(S_OLD_UID.pack(len(u), size))
282 for u, size in self._older_data_uuids:
283 s.append(u)
284
256 285 s.append(self._sidedata_uuid)
286 for u, size in self._older_sidedata_uuids:
287 s.append(S_OLD_UID.pack(len(u), size))
288 for u, size in self._older_sidedata_uuids:
289 s.append(u)
257 290 return b''.join(s)
258 291
259 292
@@ -272,6 +305,19 def default_docket(revlog, version_heade
272 305 return docket
273 306
274 307
308 def _parse_old_uids(get_data, count):
309 all_sizes = []
310 all_uids = []
311 for i in range(0, count):
312 raw = get_data(S_OLD_UID.size)
313 all_sizes.append(S_OLD_UID.unpack(raw))
314
315 for uid_size, file_size in all_sizes:
316 uid = get_data(uid_size)
317 all_uids.append((uid, file_size))
318 return all_uids
319
320
275 321 def parse_docket(revlog, data, use_pending=False):
276 322 """given some docket data return a docket object for the given revlog"""
277 323 header = S_HEADER.unpack(data[: S_HEADER.size])
@@ -297,12 +343,21 def parse_docket(revlog, data, use_pendi
297 343 index_uuid_size = next(iheader)
298 344 index_uuid = get_data(index_uuid_size)
299 345
346 older_index_uuid_count = next(iheader)
347 older_index_uuids = _parse_old_uids(get_data, older_index_uuid_count)
348
300 349 data_uuid_size = next(iheader)
301 350 data_uuid = get_data(data_uuid_size)
302 351
352 older_data_uuid_count = next(iheader)
353 older_data_uuids = _parse_old_uids(get_data, older_data_uuid_count)
354
303 355 sidedata_uuid_size = next(iheader)
304 356 sidedata_uuid = get_data(sidedata_uuid_size)
305 357
358 older_sidedata_uuid_count = next(iheader)
359 older_sidedata_uuids = _parse_old_uids(get_data, older_sidedata_uuid_count)
360
306 361 index_size = next(iheader)
307 362
308 363 pending_index_size = next(iheader)
@@ -322,8 +377,11 def parse_docket(revlog, data, use_pendi
322 377 use_pending=use_pending,
323 378 version_header=version_header,
324 379 index_uuid=index_uuid,
380 older_index_uuids=older_index_uuids,
325 381 data_uuid=data_uuid,
382 older_data_uuids=older_data_uuids,
326 383 sidedata_uuid=sidedata_uuid,
384 older_sidedata_uuids=older_sidedata_uuids,
327 385 index_end=index_size,
328 386 pending_index_end=pending_index_size,
329 387 data_end=data_size,
General Comments 0
You need to be logged in to leave comments. Login now