##// END OF EJS Templates
revlog: factor the logic to determine the delta compression out...
marmoute -
r48245:c6844912 default
parent child Browse files
Show More
@@ -2437,21 +2437,9 b' class revlog(object):'
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:
@@ -18,6 +18,9 b' from ..i18n import _'
18 from ..pycompat import getattr
18 from ..pycompat import getattr
19
19
20 from .constants import (
20 from .constants import (
21 COMP_MODE_DEFAULT,
22 COMP_MODE_INLINE,
23 COMP_MODE_PLAIN,
21 REVIDX_ISCENSORED,
24 REVIDX_ISCENSORED,
22 REVIDX_RAWTEXT_CHANGING_FLAGS,
25 REVIDX_RAWTEXT_CHANGING_FLAGS,
23 )
26 )
@@ -1113,3 +1116,28 b' class deltacomputer(object):'
1113 if deltainfo is None:
1116 if deltainfo is None:
1114 deltainfo = self._fullsnapshotinfo(fh, revinfo)
1117 deltainfo = self._fullsnapshotinfo(fh, revinfo)
1115 return deltainfo
1118 return deltainfo
1119
1120
1121 def delta_compression(default_compression_header, deltainfo):
1122 """return (COMPRESSION_MODE, deltainfo)
1123
1124 used by revlog v2+ format to dispatch between PLAIN and DEFAULT
1125 compression.
1126 """
1127 h, d = deltainfo.data
1128 compression_mode = COMP_MODE_INLINE
1129 if not h and not d:
1130 # not data to store at all... declare them uncompressed
1131 compression_mode = COMP_MODE_PLAIN
1132 elif not h:
1133 t = d[0:1]
1134 if t == b'\0':
1135 compression_mode = COMP_MODE_PLAIN
1136 elif t == default_compression_header:
1137 compression_mode = COMP_MODE_DEFAULT
1138 elif h == b'u':
1139 # we have a more efficient way to declare uncompressed
1140 h = b''
1141 compression_mode = COMP_MODE_PLAIN
1142 deltainfo = drop_u_compression(deltainfo)
1143 return compression_mode, deltainfo
General Comments 0
You need to be logged in to leave comments. Login now