Mercurial > hg-stable
comparison mercurial/revlog.py @ 41204:e3cfe0702eac
revlog: inline opener options logic into _loadindex()
We always call _loadindex() during __init__. But we also call
_loadindex() as part of censorrevision(). Before, when reloading
the index during censorrevision(), we would lose the configured
mmapindexthreshold setting from the opener. By inlining the
logic in _loadindex(), we ensure that opener options are always
respected when loading the index.
Differential Revision: https://phab.mercurial-scm.org/D5563
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 09 Jan 2019 16:18:00 -0800 |
parents | d0de4fdd87aa |
children | 3f807237dc94 |
comparison
equal
deleted
inserted
replaced
41203:d0de4fdd87aa | 41204:e3cfe0702eac |
---|---|
382 self._flagprocessors = dict(_flagprocessors) | 382 self._flagprocessors = dict(_flagprocessors) |
383 | 383 |
384 # 2-tuple of file handles being used for active writing. | 384 # 2-tuple of file handles being used for active writing. |
385 self._writinghandles = None | 385 self._writinghandles = None |
386 | 386 |
387 self._loadindex() | |
388 | |
389 def _loadindex(self): | |
387 mmapindexthreshold = None | 390 mmapindexthreshold = None |
388 opts = getattr(opener, 'options', {}) or {} | 391 opts = getattr(self.opener, 'options', {}) or {} |
389 | 392 |
390 if 'revlogv2' in opts: | 393 if 'revlogv2' in opts: |
391 versionflags = REVLOGV2 | FLAG_INLINE_DATA | 394 versionflags = REVLOGV2 | FLAG_INLINE_DATA |
392 elif 'revlogv1' in opts: | 395 elif 'revlogv1' in opts: |
393 versionflags = REVLOGV1 | FLAG_INLINE_DATA | 396 versionflags = REVLOGV1 | FLAG_INLINE_DATA |
429 'greater than 0') % self._chunkcachesize) | 432 'greater than 0') % self._chunkcachesize) |
430 elif self._chunkcachesize & (self._chunkcachesize - 1): | 433 elif self._chunkcachesize & (self._chunkcachesize - 1): |
431 raise error.RevlogError(_('revlog chunk cache size %r is not a ' | 434 raise error.RevlogError(_('revlog chunk cache size %r is not a ' |
432 'power of 2') % self._chunkcachesize) | 435 'power of 2') % self._chunkcachesize) |
433 | 436 |
434 self._loadindex(versionflags, mmapindexthreshold) | |
435 | |
436 def _loadindex(self, versionflags, mmapindexthreshold): | |
437 indexdata = '' | 437 indexdata = '' |
438 self._initempty = True | 438 self._initempty = True |
439 try: | 439 try: |
440 with self._indexfp() as f: | 440 with self._indexfp() as f: |
441 if (mmapindexthreshold is not None and | 441 if (mmapindexthreshold is not None and |
2497 self.opener.rename(newrl.indexfile, self.indexfile) | 2497 self.opener.rename(newrl.indexfile, self.indexfile) |
2498 if not self._inline: | 2498 if not self._inline: |
2499 self.opener.rename(newrl.datafile, self.datafile) | 2499 self.opener.rename(newrl.datafile, self.datafile) |
2500 | 2500 |
2501 self.clearcaches() | 2501 self.clearcaches() |
2502 self._loadindex(self.version, None) | 2502 self._loadindex() |
2503 | 2503 |
2504 def verifyintegrity(self, state): | 2504 def verifyintegrity(self, state): |
2505 """Verifies the integrity of the revlog. | 2505 """Verifies the integrity of the revlog. |
2506 | 2506 |
2507 Yields ``revlogproblem`` instances describing problems that are | 2507 Yields ``revlogproblem`` instances describing problems that are |