Show More
@@ -533,12 +533,13 b' static PyObject *index_replace_sidedata_' | |||||
533 | { |
|
533 | { | |
534 | uint64_t offset_flags, sidedata_offset; |
|
534 | uint64_t offset_flags, sidedata_offset; | |
535 | int rev; |
|
535 | int rev; | |
|
536 | char comp_mode; | |||
536 | Py_ssize_t sidedata_comp_len; |
|
537 | Py_ssize_t sidedata_comp_len; | |
537 | char *data; |
|
538 | char *data; | |
538 | #if LONG_MAX == 0x7fffffffL |
|
539 | #if LONG_MAX == 0x7fffffffL | |
539 | const char *const sidedata_format = PY23("nKiK", "nKiK"); |
|
540 | const char *const sidedata_format = PY23("nKiKB", "nKiKB"); | |
540 | #else |
|
541 | #else | |
541 | const char *const sidedata_format = PY23("nkik", "nkik"); |
|
542 | const char *const sidedata_format = PY23("nkikB", "nkikB"); | |
542 | #endif |
|
543 | #endif | |
543 |
|
544 | |||
544 | if (self->entry_size == v1_entry_size || self->inlined) { |
|
545 | if (self->entry_size == v1_entry_size || self->inlined) { | |
@@ -553,7 +554,7 b' static PyObject *index_replace_sidedata_' | |||||
553 | } |
|
554 | } | |
554 |
|
555 | |||
555 | if (!PyArg_ParseTuple(args, sidedata_format, &rev, &sidedata_offset, |
|
556 | if (!PyArg_ParseTuple(args, sidedata_format, &rev, &sidedata_offset, | |
556 | &sidedata_comp_len, &offset_flags)) |
|
557 | &sidedata_comp_len, &offset_flags, &comp_mode)) | |
557 | return NULL; |
|
558 | return NULL; | |
558 |
|
559 | |||
559 | if (rev < 0 || rev >= index_length(self)) { |
|
560 | if (rev < 0 || rev >= index_length(self)) { | |
@@ -573,6 +574,7 b' static PyObject *index_replace_sidedata_' | |||||
573 | putbe64(offset_flags, data); |
|
574 | putbe64(offset_flags, data); | |
574 | putbe64(sidedata_offset, data + 64); |
|
575 | putbe64(sidedata_offset, data + 64); | |
575 | putbe32(sidedata_comp_len, data + 72); |
|
576 | putbe32(sidedata_comp_len, data + 72); | |
|
577 | data[76] = (data[76] & ~(3 << 2)) | ((comp_mode & 3) << 2); | |||
576 |
|
578 | |||
577 | Py_RETURN_NONE; |
|
579 | Py_RETURN_NONE; | |
578 | } |
|
580 | } |
@@ -297,7 +297,12 b' class Index2Mixin(object):' | |||||
297 | index_format = revlog_constants.INDEX_ENTRY_V2 |
|
297 | index_format = revlog_constants.INDEX_ENTRY_V2 | |
298 |
|
298 | |||
299 | def replace_sidedata_info( |
|
299 | def replace_sidedata_info( | |
300 | self, rev, sidedata_offset, sidedata_length, offset_flags |
|
300 | self, | |
|
301 | rev, | |||
|
302 | sidedata_offset, | |||
|
303 | sidedata_length, | |||
|
304 | offset_flags, | |||
|
305 | compression_mode, | |||
301 | ): |
|
306 | ): | |
302 | """ |
|
307 | """ | |
303 | Replace an existing index entry's sidedata offset and length with new |
|
308 | Replace an existing index entry's sidedata offset and length with new | |
@@ -316,6 +321,7 b' class Index2Mixin(object):' | |||||
316 | entry[0] = offset_flags |
|
321 | entry[0] = offset_flags | |
317 | entry[8] = sidedata_offset |
|
322 | entry[8] = sidedata_offset | |
318 | entry[9] = sidedata_length |
|
323 | entry[9] = sidedata_length | |
|
324 | entry[11] = compression_mode | |||
319 | entry = tuple(entry) |
|
325 | entry = tuple(entry) | |
320 | new = self._pack_entry(entry) |
|
326 | new = self._pack_entry(entry) | |
321 | self._extra[rev - self._lgt] = new |
|
327 | self._extra[rev - self._lgt] = new |
@@ -3381,6 +3381,26 b' class revlog(object):' | |||||
3381 | serialized_sidedata = sidedatautil.serialize_sidedata( |
|
3381 | serialized_sidedata = sidedatautil.serialize_sidedata( | |
3382 | new_sidedata |
|
3382 | new_sidedata | |
3383 | ) |
|
3383 | ) | |
|
3384 | ||||
|
3385 | sidedata_compression_mode = COMP_MODE_INLINE | |||
|
3386 | if serialized_sidedata and self.hassidedata: | |||
|
3387 | sidedata_compression_mode = COMP_MODE_PLAIN | |||
|
3388 | h, comp_sidedata = self.compress(serialized_sidedata) | |||
|
3389 | if ( | |||
|
3390 | h != b'u' | |||
|
3391 | and comp_sidedata[0] != b'\0' | |||
|
3392 | and len(comp_sidedata) < len(serialized_sidedata) | |||
|
3393 | ): | |||
|
3394 | assert not h | |||
|
3395 | if ( | |||
|
3396 | comp_sidedata[0] | |||
|
3397 | == self._docket.default_compression_header | |||
|
3398 | ): | |||
|
3399 | sidedata_compression_mode = COMP_MODE_DEFAULT | |||
|
3400 | serialized_sidedata = comp_sidedata | |||
|
3401 | else: | |||
|
3402 | sidedata_compression_mode = COMP_MODE_INLINE | |||
|
3403 | serialized_sidedata = comp_sidedata | |||
3384 | if entry[8] != 0 or entry[9] != 0: |
|
3404 | if entry[8] != 0 or entry[9] != 0: | |
3385 | # rewriting entries that already have sidedata is not |
|
3405 | # rewriting entries that already have sidedata is not | |
3386 | # supported yet, because it introduces garbage data in the |
|
3406 | # supported yet, because it introduces garbage data in the | |
@@ -3395,6 +3415,7 b' class revlog(object):' | |||||
3395 | current_offset, |
|
3415 | current_offset, | |
3396 | len(serialized_sidedata), |
|
3416 | len(serialized_sidedata), | |
3397 | new_offset_flags, |
|
3417 | new_offset_flags, | |
|
3418 | sidedata_compression_mode, | |||
3398 | ) |
|
3419 | ) | |
3399 |
|
3420 | |||
3400 | # the sidedata computation might have move the file cursors around |
|
3421 | # the sidedata computation might have move the file cursors around |
General Comments 0
You need to be logged in to leave comments.
Login now