Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 52884:8de68446a5bd
index: remember the generaldelta config instead of getting it from the revlog
The code (especially the Rust code) was jumping in 4 dimensions to make sense
of what was going on because it wrongly assumed that we needed to somehow
be able to ask a generaldelta index for a non-generaldelta delta chain, which
doesn't make any sense.
Removing the cargo-culted/vestigial code, this is cleaner and less confusing.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Thu, 13 Feb 2025 13:13:05 +0100 |
parents | 384ecbc8f8ca |
children |
comparison
equal
deleted
inserted
replaced
52883:384ecbc8f8ca | 52884:8de68446a5bd |
---|---|
207 warning = attr.ib(default=None, type=Optional[bytes]) | 207 warning = attr.ib(default=None, type=Optional[bytes]) |
208 error = attr.ib(default=None, type=Optional[bytes]) | 208 error = attr.ib(default=None, type=Optional[bytes]) |
209 node = attr.ib(default=None, type=Optional[bytes]) | 209 node = attr.ib(default=None, type=Optional[bytes]) |
210 | 210 |
211 | 211 |
212 def parse_index_v1(data, inline): | 212 def parse_index_v1(data, inline, uses_generaldelta): |
213 # call the C implementation to parse the index data | 213 # call the C implementation to parse the index data |
214 index, cache = parsers.parse_index2(data, inline) | 214 index, cache = parsers.parse_index2(data, inline, uses_generaldelta) |
215 return index, cache | 215 return index, cache |
216 | 216 |
217 | 217 |
218 def parse_index_v2(data, inline): | 218 def parse_index_v2(data, inline, uses_generaldelta): |
219 # call the C implementation to parse the index data | 219 # call the C implementation to parse the index data |
220 index, cache = parsers.parse_index2(data, inline, format=REVLOGV2) | 220 index, cache = parsers.parse_index2( |
221 data, inline, uses_generaldelta, format=REVLOGV2 | |
222 ) | |
221 return index, cache | 223 return index, cache |
222 | 224 |
223 | 225 |
224 def parse_index_cl_v2(data, inline): | 226 def parse_index_cl_v2(data, inline, uses_generaldelta): |
225 # call the C implementation to parse the index data | 227 # call the C implementation to parse the index data |
226 index, cache = parsers.parse_index2(data, inline, format=CHANGELOGV2) | 228 index, cache = parsers.parse_index2( |
229 data, inline, uses_generaldelta, format=CHANGELOGV2 | |
230 ) | |
227 return index, cache | 231 return index, cache |
228 | 232 |
229 | 233 |
230 if hasattr(parsers, 'parse_index_devel_nodemap'): | 234 if hasattr(parsers, 'parse_index_devel_nodemap'): |
231 | 235 |
232 def parse_index_v1_nodemap(data, inline): | 236 def parse_index_v1_nodemap(data, inline, uses_generaldelta): |
233 index, cache = parsers.parse_index_devel_nodemap(data, inline) | 237 index, cache = parsers.parse_index_devel_nodemap( |
238 data, inline, uses_generaldelta | |
239 ) | |
234 return index, cache | 240 return index, cache |
235 | 241 |
236 else: | 242 else: |
237 parse_index_v1_nodemap = None | 243 parse_index_v1_nodemap = None |
238 | 244 |
517 | 523 |
518 Returns a 2-tuple of (chain, stopped) where ``chain`` is a list of | 524 Returns a 2-tuple of (chain, stopped) where ``chain`` is a list of |
519 revs in ascending order and ``stopped`` is a bool indicating whether | 525 revs in ascending order and ``stopped`` is a bool indicating whether |
520 ``stoprev`` was hit. | 526 ``stoprev`` was hit. |
521 """ | 527 """ |
522 generaldelta = self.delta_config.general_delta | |
523 # Try C implementation. | 528 # Try C implementation. |
524 try: | 529 try: |
525 return self.index.deltachain( | 530 return self.index.deltachain( |
526 rev, stoprev, generaldelta | 531 rev, stoprev |
527 ) # pytype: disable=attribute-error | 532 ) # pytype: disable=attribute-error |
528 except AttributeError: | 533 except AttributeError: |
529 pass | 534 pass |
530 | 535 |
531 chain = [] | 536 chain = [] |
532 | 537 |
533 # Alias to prevent attribute lookup in tight loop. | 538 # Alias to prevent attribute lookup in tight loop. |
534 index = self.index | 539 index = self.index |
540 generaldelta = self.delta_config.general_delta | |
535 | 541 |
536 iterrev = rev | 542 iterrev = rev |
537 e = index[iterrev] | 543 e = index[iterrev] |
538 while iterrev != e[3] and iterrev != stoprev: | 544 while iterrev != e[3] and iterrev != stoprev: |
539 chain.append(iterrev) | 545 chain.append(iterrev) |
1812 # Let the Rust code parse its own index | 1818 # Let the Rust code parse its own index |
1813 index, chunkcache = (index_data, None) | 1819 index, chunkcache = (index_data, None) |
1814 self.uses_rust = True | 1820 self.uses_rust = True |
1815 else: | 1821 else: |
1816 try: | 1822 try: |
1817 d = self._parse_index(index_data, self._inline) | 1823 d = self._parse_index( |
1824 index_data, self._inline, self.delta_config.general_delta | |
1825 ) | |
1818 index, chunkcache = d | 1826 index, chunkcache = d |
1819 self._register_nodemap_info(index) | 1827 self._register_nodemap_info(index) |
1820 except (ValueError, IndexError): | 1828 except (ValueError, IndexError): |
1821 raise error.RevlogError( | 1829 raise error.RevlogError( |
1822 _(b"index %s is corrupted") % self.display_id | 1830 _(b"index %s is corrupted") % self.display_id |