Mercurial > hg
comparison mercurial/cext/revlog.c @ 47251:6bfa6c2c5f15
revlogv2: preserve the compression mode on disk
The value is still the same and still not treated, but now it exists one disk.
Differential Revision: https://phab.mercurial-scm.org/D10648
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 03 May 2021 18:41:51 +0200 |
parents | 4dca422d3907 |
children | 2b69555e4875 |
comparison
equal
deleted
inserted
replaced
47250:4dca422d3907 | 47251:6bfa6c2c5f15 |
---|---|
336 c_node_id = data + 32; | 336 c_node_id = data + 32; |
337 | 337 |
338 if (self->format_version == format_v1) { | 338 if (self->format_version == format_v1) { |
339 sidedata_offset = 0; | 339 sidedata_offset = 0; |
340 sidedata_comp_len = 0; | 340 sidedata_comp_len = 0; |
341 data_comp_mode = comp_mode_inline; | |
341 } else { | 342 } else { |
342 sidedata_offset = getbe64(data + 64); | 343 sidedata_offset = getbe64(data + 64); |
343 sidedata_comp_len = getbe32(data + 72); | 344 sidedata_comp_len = getbe32(data + 72); |
344 } | 345 data_comp_mode = data[76]; |
345 | 346 } |
346 data_comp_mode = comp_mode_inline; | 347 |
347 return Py_BuildValue(tuple_format, offset_flags, comp_len, uncomp_len, | 348 return Py_BuildValue(tuple_format, offset_flags, comp_len, uncomp_len, |
348 base_rev, link_rev, parent_1, parent_2, c_node_id, | 349 base_rev, link_rev, parent_1, parent_2, c_node_id, |
349 self->nodelen, sidedata_offset, sidedata_comp_len, | 350 self->nodelen, sidedata_offset, sidedata_comp_len, |
350 data_comp_mode); | 351 data_comp_mode); |
351 } | 352 } |
464 | 465 |
465 if (c_node_id_len != self->nodelen) { | 466 if (c_node_id_len != self->nodelen) { |
466 PyErr_SetString(PyExc_TypeError, "invalid node"); | 467 PyErr_SetString(PyExc_TypeError, "invalid node"); |
467 return NULL; | 468 return NULL; |
468 } | 469 } |
469 if (data_comp_mode != comp_mode_inline) { | 470 if (self->format_version == format_v1 && |
471 data_comp_mode != comp_mode_inline) { | |
470 PyErr_Format(PyExc_ValueError, | 472 PyErr_Format(PyExc_ValueError, |
471 "invalid data compression mode: %i", | 473 "invalid data compression mode: %i", |
472 data_comp_mode); | 474 data_comp_mode); |
473 return NULL; | 475 return NULL; |
474 } | 476 } |
497 /* Padding since SHA-1 is only 20 bytes for now */ | 499 /* Padding since SHA-1 is only 20 bytes for now */ |
498 memset(data + 32 + c_node_id_len, 0, 32 - c_node_id_len); | 500 memset(data + 32 + c_node_id_len, 0, 32 - c_node_id_len); |
499 if (self->format_version == format_v2) { | 501 if (self->format_version == format_v2) { |
500 putbe64(sidedata_offset, data + 64); | 502 putbe64(sidedata_offset, data + 64); |
501 putbe32(sidedata_comp_len, data + 72); | 503 putbe32(sidedata_comp_len, data + 72); |
504 data[76] = (char)data_comp_mode; | |
502 /* Padding for 96 bytes alignment */ | 505 /* Padding for 96 bytes alignment */ |
503 memset(data + 76, 0, self->entry_size - 76); | 506 memset(data + 77, 0, self->entry_size - 77); |
504 } | 507 } |
505 | 508 |
506 if (self->ntinitialized) | 509 if (self->ntinitialized) |
507 nt_insert(&self->nt, c_node_id, rev); | 510 nt_insert(&self->nt, c_node_id, rev); |
508 | 511 |