Show More
@@ -35,6 +35,7 b' from .i18n import _' | |||
|
35 | 35 | from .pycompat import getattr |
|
36 | 36 | from .revlogutils.constants import ( |
|
37 | 37 | ALL_KINDS, |
|
38 | COMP_MODE_DEFAULT, | |
|
38 | 39 | COMP_MODE_INLINE, |
|
39 | 40 | COMP_MODE_PLAIN, |
|
40 | 41 | FEATURES_BY_VERSION, |
@@ -708,6 +709,15 b' class revlog(object):' | |||
|
708 | 709 | engine = util.compengines[self._compengine] |
|
709 | 710 | return engine.revlogcompressor(self._compengineopts) |
|
710 | 711 | |
|
712 | @util.propertycache | |
|
713 | def _decompressor(self): | |
|
714 | """the default decompressor""" | |
|
715 | if self._docket is None: | |
|
716 | return None | |
|
717 | t = self._docket.default_compression_header | |
|
718 | c = self._get_decompressor(t) | |
|
719 | return c.decompress | |
|
720 | ||
|
711 | 721 | def _indexfp(self): |
|
712 | 722 | """file object for the revlog's index file""" |
|
713 | 723 | return self.opener(self._indexfile, mode=b"r") |
@@ -1776,6 +1786,8 b' class revlog(object):' | |||
|
1776 | 1786 | data = self._getsegmentforrevs(rev, rev, df=df)[1] |
|
1777 | 1787 | if compression_mode == COMP_MODE_PLAIN: |
|
1778 | 1788 | return data |
|
1789 | elif compression_mode == COMP_MODE_DEFAULT: | |
|
1790 | return self._decompressor(data) | |
|
1779 | 1791 | elif compression_mode == COMP_MODE_INLINE: |
|
1780 | 1792 | return self.decompress(data) |
|
1781 | 1793 | else: |
@@ -1829,6 +1841,8 b' class revlog(object):' | |||
|
1829 | 1841 | return [self._chunk(rev, df=df) for rev in revschunk] |
|
1830 | 1842 | |
|
1831 | 1843 | decomp = self.decompress |
|
1844 | # self._decompressor might be None, but will not be used in that case | |
|
1845 | def_decomp = self._decompressor | |
|
1832 | 1846 | for rev in revschunk: |
|
1833 | 1847 | chunkstart = start(rev) |
|
1834 | 1848 | if inline: |
@@ -1840,6 +1854,8 b' class revlog(object):' | |||
|
1840 | 1854 | ladd(c) |
|
1841 | 1855 | elif comp_mode == COMP_MODE_INLINE: |
|
1842 | 1856 | ladd(decomp(c)) |
|
1857 | elif comp_mode == COMP_MODE_DEFAULT: | |
|
1858 | ladd(def_decomp(c)) | |
|
1843 | 1859 | else: |
|
1844 | 1860 | msg = 'unknown compression mode %d' |
|
1845 | 1861 | msg %= comp_mode |
@@ -2489,8 +2505,12 b' class revlog(object):' | |||
|
2489 | 2505 | if not h and not d: |
|
2490 | 2506 | # not data to store at all... declare them uncompressed |
|
2491 | 2507 | compression_mode = COMP_MODE_PLAIN |
|
2492 |
elif not h |
|
|
2508 | elif not h: | |
|
2509 | t = d[0:1] | |
|
2510 | if t == b'\0': | |
|
2493 | 2511 | compression_mode = COMP_MODE_PLAIN |
|
2512 | elif t == self._docket.default_compression_header: | |
|
2513 | compression_mode = COMP_MODE_DEFAULT | |
|
2494 | 2514 | elif h == b'u': |
|
2495 | 2515 | # we have a more efficient way to declare uncompressed |
|
2496 | 2516 | h = b'' |
@@ -123,6 +123,16 b' REVIDX_RAWTEXT_CHANGING_FLAGS = REVIDX_I' | |||
|
123 | 123 | # chunk value. Without any header information prefixed. |
|
124 | 124 | COMP_MODE_PLAIN = 0 |
|
125 | 125 | |
|
126 | # Chunk use the "default compression" for the revlog (usually defined in the | |
|
127 | # revlog docket). A header is still used. | |
|
128 | # | |
|
129 | # XXX: keeping a header is probably not useful and we should probably drop it. | |
|
130 | # | |
|
131 | # XXX: The value of allow mixed type of compression in the revlog is unclear | |
|
132 | # and we should consider making PLAIN/DEFAULT the only available mode for | |
|
133 | # revlog v2, disallowing INLINE mode. | |
|
134 | COMP_MODE_DEFAULT = 1 | |
|
135 | ||
|
126 | 136 | # Chunk use a compression mode stored "inline" at the start of the chunk |
|
127 | 137 | # itself. This is the mode always used for revlog version "0" and "1" |
|
128 | 138 | COMP_MODE_INLINE = 2 |
@@ -21,6 +21,7 b' import struct' | |||
|
21 | 21 | |
|
22 | 22 | from .. import ( |
|
23 | 23 | error, |
|
24 | util, | |
|
24 | 25 | ) |
|
25 | 26 | |
|
26 | 27 | from . import ( |
@@ -36,7 +37,8 b' from . import (' | |||
|
36 | 37 | # * 8 bytes: pending size of index-data |
|
37 | 38 | # * 8 bytes: size of data |
|
38 | 39 | # * 8 bytes: pending size of data |
|
39 | S_HEADER = struct.Struct(constants.INDEX_HEADER.format + 'LLLL') | |
|
40 | # * 1 bytes: default compression header | |
|
41 | S_HEADER = struct.Struct(constants.INDEX_HEADER.format + 'LLLLc') | |
|
40 | 42 | |
|
41 | 43 | |
|
42 | 44 | class RevlogDocket(object): |
@@ -51,6 +53,7 b' class RevlogDocket(object):' | |||
|
51 | 53 | pending_index_end=0, |
|
52 | 54 | data_end=0, |
|
53 | 55 | pending_data_end=0, |
|
56 | default_compression_header=None, | |
|
54 | 57 | ): |
|
55 | 58 | self._version_header = version_header |
|
56 | 59 | self._read_only = bool(use_pending) |
@@ -71,6 +74,7 b' class RevlogDocket(object):' | |||
|
71 | 74 | else: |
|
72 | 75 | self._index_end = self._initial_index_end |
|
73 | 76 | self._data_end = self._initial_data_end |
|
77 | self.default_compression_header = default_compression_header | |
|
74 | 78 | |
|
75 | 79 | def index_filepath(self): |
|
76 | 80 | """file path to the current index file associated to this docket""" |
@@ -134,6 +138,7 b' class RevlogDocket(object):' | |||
|
134 | 138 | self._index_end, |
|
135 | 139 | official_data_end, |
|
136 | 140 | self._data_end, |
|
141 | self.default_compression_header, | |
|
137 | 142 | ) |
|
138 | 143 | return S_HEADER.pack(*data) |
|
139 | 144 | |
@@ -142,7 +147,12 b' def default_docket(revlog, version_heade' | |||
|
142 | 147 | """given a revlog version a new docket object for the given revlog""" |
|
143 | 148 | if (version_header & 0xFFFF) != constants.REVLOGV2: |
|
144 | 149 | return None |
|
145 | docket = RevlogDocket(revlog, version_header=version_header) | |
|
150 | comp = util.compengines[revlog._compengine].revlogheader() | |
|
151 | docket = RevlogDocket( | |
|
152 | revlog, | |
|
153 | version_header=version_header, | |
|
154 | default_compression_header=comp, | |
|
155 | ) | |
|
146 | 156 | docket._dirty = True |
|
147 | 157 | return docket |
|
148 | 158 | |
@@ -155,6 +165,7 b' def parse_docket(revlog, data, use_pendi' | |||
|
155 | 165 | pending_index_size = header[2] |
|
156 | 166 | data_size = header[3] |
|
157 | 167 | pending_data_size = header[4] |
|
168 | default_compression_header = header[5] | |
|
158 | 169 | docket = RevlogDocket( |
|
159 | 170 | revlog, |
|
160 | 171 | use_pending=use_pending, |
@@ -163,5 +174,6 b' def parse_docket(revlog, data, use_pendi' | |||
|
163 | 174 | pending_index_end=pending_index_size, |
|
164 | 175 | data_end=data_size, |
|
165 | 176 | pending_data_end=pending_data_size, |
|
177 | default_compression_header=default_compression_header, | |
|
166 | 178 | ) |
|
167 | 179 | return docket |
General Comments 0
You need to be logged in to leave comments.
Login now