Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 47158:b6e1fe7ac24b
revlog: split the option initialisation in its own method
The part of the code is huge, keeping it separated will keep the `_loadindex`
method simpler and help keeping logic well insulated.
Differential Revision: https://phab.mercurial-scm.org/D10570
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 03 May 2021 12:21:35 +0200 |
parents | 47ffc754989a |
children | c6b8d5d91e73 |
comparison
equal
deleted
inserted
replaced
47157:47ffc754989a | 47158:b6e1fe7ac24b |
---|---|
361 | 361 |
362 self._loadindex() | 362 self._loadindex() |
363 | 363 |
364 self._concurrencychecker = concurrencychecker | 364 self._concurrencychecker = concurrencychecker |
365 | 365 |
366 def _loadindex(self): | 366 def _init_opts(self): |
367 """process options (from above/config) to setup associated default revlog mode | |
368 | |
369 These values might be affected when actually reading on disk information. | |
370 | |
371 The relevant values are returned for use in _loadindex(). | |
372 | |
373 * newversionflags: | |
374 version header to use if we need to create a new revlog | |
375 | |
376 * mmapindexthreshold: | |
377 minimal index size for start to use mmap | |
378 | |
379 * force_nodemap: | |
380 force the usage of a "development" version of the nodemap code | |
381 """ | |
367 mmapindexthreshold = None | 382 mmapindexthreshold = None |
368 opts = self.opener.options | 383 opts = self.opener.options |
369 | 384 |
370 if b'revlogv2' in opts: | 385 if b'revlogv2' in opts: |
371 newversionflags = REVLOGV2 | FLAG_INLINE_DATA | 386 newversionflags = REVLOGV2 | FLAG_INLINE_DATA |
424 elif self._chunkcachesize & (self._chunkcachesize - 1): | 439 elif self._chunkcachesize & (self._chunkcachesize - 1): |
425 raise error.RevlogError( | 440 raise error.RevlogError( |
426 _(b'revlog chunk cache size %r is not a power of 2') | 441 _(b'revlog chunk cache size %r is not a power of 2') |
427 % self._chunkcachesize | 442 % self._chunkcachesize |
428 ) | 443 ) |
429 | 444 force_nodemap = opts.get(b'devel-force-nodemap', False) |
445 return newversionflags, mmapindexthreshold, force_nodemap | |
446 | |
447 def _loadindex(self): | |
448 | |
449 newversionflags, mmapindexthreshold, force_nodemap = self._init_opts() | |
430 indexdata = b'' | 450 indexdata = b'' |
431 self._initempty = True | 451 self._initempty = True |
432 try: | 452 try: |
433 with self._indexfp() as f: | 453 with self._indexfp() as f: |
434 if ( | 454 if ( |
503 | 523 |
504 self._storedeltachains = True | 524 self._storedeltachains = True |
505 | 525 |
506 devel_nodemap = ( | 526 devel_nodemap = ( |
507 self.nodemap_file | 527 self.nodemap_file |
508 and opts.get(b'devel-force-nodemap', False) | 528 and force_nodemap |
509 and parse_index_v1_nodemap is not None | 529 and parse_index_v1_nodemap is not None |
510 ) | 530 ) |
511 | 531 |
512 use_rust_index = False | 532 use_rust_index = False |
513 if rustrevlog is not None: | 533 if rustrevlog is not None: |