Show More
@@ -261,36 +261,14 b' def v2_censor(rl, tr, censornode, tombst' | |||||
261 | new_sidedata_file.seek(0, os.SEEK_END) |
|
261 | new_sidedata_file.seek(0, os.SEEK_END) | |
262 | assert new_sidedata_file.tell() == sidedata_cutoff |
|
262 | assert new_sidedata_file.tell() == sidedata_cutoff | |
263 |
|
263 | |||
264 |
|
|
264 | # writing the censored revision | |
265 |
|
|
265 | _rewrite_censor( | |
266 |
|
266 | rl, | ||
267 | # XXX consider trying the default compression too |
|
267 | old_index, | |
268 | new_data_size = len(tombstone) |
|
268 | open_files, | |
269 | new_data_offset = new_data_file.tell() |
|
269 | censor_rev, | |
270 |
|
|
270 | tombstone, | |
271 |
|
||||
272 | # we are not adding any sidedata as they might leak info about the censored version |
|
|||
273 |
|
||||
274 | new_entry = revlogutils.entry( |
|
|||
275 | flags=constants.REVIDX_ISCENSORED, |
|
|||
276 | data_offset=new_data_offset, |
|
|||
277 | data_compressed_length=new_data_size, |
|
|||
278 | data_uncompressed_length=new_data_size, |
|
|||
279 | data_delta_base=censor_rev, |
|
|||
280 | link_rev=entry[ENTRY_LINK_REV], |
|
|||
281 | parent_rev_1=entry[ENTRY_PARENT_1], |
|
|||
282 | parent_rev_2=entry[ENTRY_PARENT_2], |
|
|||
283 | node_id=entry[ENTRY_NODE_ID], |
|
|||
284 | sidedata_offset=0, |
|
|||
285 | sidedata_compressed_length=0, |
|
|||
286 | data_compression_mode=COMP_MODE_PLAIN, |
|
|||
287 | sidedata_compression_mode=COMP_MODE_PLAIN, |
|
|||
288 | ) |
|
271 | ) | |
289 | rl.index.append(new_entry) |
|
|||
290 | entry_bin = rl.index.entry_binary(censor_rev) |
|
|||
291 | new_index_file.write(entry_bin) |
|
|||
292 | docket.index_end = new_index_file.tell() |
|
|||
293 | docket.data_end = new_data_file.tell() |
|
|||
294 |
|
272 | |||
295 | #### Writing all subsequent revisions |
|
273 | #### Writing all subsequent revisions | |
296 | for rev in range(censor_rev + 1, len(old_index)): |
|
274 | for rev in range(censor_rev + 1, len(old_index)): | |
@@ -358,3 +336,54 b' def v2_censor(rl, tr, censornode, tombst' | |||||
358 | docket.sidedata_end = new_sidedata_file.tell() |
|
336 | docket.sidedata_end = new_sidedata_file.tell() | |
359 |
|
337 | |||
360 | docket.write(transaction=None, stripping=True) |
|
338 | docket.write(transaction=None, stripping=True) | |
|
339 | ||||
|
340 | ||||
|
341 | def _rewrite_censor( | |||
|
342 | revlog, | |||
|
343 | old_index, | |||
|
344 | all_files, | |||
|
345 | rev, | |||
|
346 | tombstone, | |||
|
347 | ): | |||
|
348 | """rewrite and append a censored revision""" | |||
|
349 | ( | |||
|
350 | old_data_file, | |||
|
351 | old_sidedata_file, | |||
|
352 | new_index_file, | |||
|
353 | new_data_file, | |||
|
354 | new_sidedata_file, | |||
|
355 | ) = all_files | |||
|
356 | entry = old_index[rev] | |||
|
357 | ||||
|
358 | # XXX consider trying the default compression too | |||
|
359 | new_data_size = len(tombstone) | |||
|
360 | new_data_offset = new_data_file.tell() | |||
|
361 | new_data_file.write(tombstone) | |||
|
362 | ||||
|
363 | # we are not adding any sidedata as they might leak info about the censored version | |||
|
364 | ||||
|
365 | link_rev = entry[ENTRY_LINK_REV] | |||
|
366 | ||||
|
367 | p1 = entry[ENTRY_PARENT_1] | |||
|
368 | p2 = entry[ENTRY_PARENT_2] | |||
|
369 | ||||
|
370 | new_entry = revlogutils.entry( | |||
|
371 | flags=constants.REVIDX_ISCENSORED, | |||
|
372 | data_offset=new_data_offset, | |||
|
373 | data_compressed_length=new_data_size, | |||
|
374 | data_uncompressed_length=new_data_size, | |||
|
375 | data_delta_base=rev, | |||
|
376 | link_rev=link_rev, | |||
|
377 | parent_rev_1=p1, | |||
|
378 | parent_rev_2=p2, | |||
|
379 | node_id=entry[ENTRY_NODE_ID], | |||
|
380 | sidedata_offset=0, | |||
|
381 | sidedata_compressed_length=0, | |||
|
382 | data_compression_mode=COMP_MODE_PLAIN, | |||
|
383 | sidedata_compression_mode=COMP_MODE_PLAIN, | |||
|
384 | ) | |||
|
385 | revlog.index.append(new_entry) | |||
|
386 | entry_bin = revlog.index.entry_binary(rev) | |||
|
387 | new_index_file.write(entry_bin) | |||
|
388 | revlog._docket.index_end = new_index_file.tell() | |||
|
389 | revlog._docket.data_end = new_data_file.tell() |
General Comments 0
You need to be logged in to leave comments.
Login now