comparison mercurial/revlog.py @ 47458:c6844912c327

revlog: factor the logic to determine the delta compression out This make the logic clearly isolated and documented and it will help use to reuse it during censors/strip. Differential Revision: https://phab.mercurial-scm.org/D10889
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 21 Jun 2021 15:00:53 +0200
parents 9cecc222c536
children f93a867a6486
comparison
equal deleted inserted replaced
47457:f70ca39d0ab8 47458:c6844912c327
2435 2435
2436 deltainfo = deltacomputer.finddeltainfo(revinfo, fh) 2436 deltainfo = deltacomputer.finddeltainfo(revinfo, fh)
2437 2437
2438 compression_mode = COMP_MODE_INLINE 2438 compression_mode = COMP_MODE_INLINE
2439 if self._docket is not None: 2439 if self._docket is not None:
2440 h, d = deltainfo.data 2440 default_comp = self._docket.default_compression_header
2441 if not h and not d: 2441 r = deltautil.delta_compression(default_comp, deltainfo)
2442 # not data to store at all... declare them uncompressed 2442 compression_mode, deltainfo = r
2443 compression_mode = COMP_MODE_PLAIN
2444 elif not h:
2445 t = d[0:1]
2446 if t == b'\0':
2447 compression_mode = COMP_MODE_PLAIN
2448 elif t == self._docket.default_compression_header:
2449 compression_mode = COMP_MODE_DEFAULT
2450 elif h == b'u':
2451 # we have a more efficient way to declare uncompressed
2452 h = b''
2453 compression_mode = COMP_MODE_PLAIN
2454 deltainfo = deltautil.drop_u_compression(deltainfo)
2455 2443
2456 sidedata_compression_mode = COMP_MODE_INLINE 2444 sidedata_compression_mode = COMP_MODE_INLINE
2457 if sidedata and self.hassidedata: 2445 if sidedata and self.hassidedata:
2458 sidedata_compression_mode = COMP_MODE_PLAIN 2446 sidedata_compression_mode = COMP_MODE_PLAIN
2459 serialized_sidedata = sidedatautil.serialize_sidedata(sidedata) 2447 serialized_sidedata = sidedatautil.serialize_sidedata(sidedata)