Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 41200:cecf3f8bccd3
revlog: always process opener options
I'm not sure when ``opener.options`` would ever be explicitly
set to None. It is definitely not possible to construct a repo
this way because ``localrepo.resolvestorevfsoptions()`` always
returns a dict and ``localrepo.makelocalrepository()`` always
sets ``opener.options`` to this value.
Because we always execute this code now, if options are empty
we defaulted to creating version 0 revlogs. So we had to change
the code slightly to fall back to the default revlog version
and flags.
As astute reader will note that it is not possible to create
version 0 revlogs now. However, I don't think it was possible
before, as this required ``opener.options`` being unset, which
I don't think was possible. I suspect this means our test
coverage for version 0 revlog repositories is possibly
non-existent! Since I don't see a config option to disable
revlog v1, I'm not even sure if we had a way to create new
repos with version 0 revlogs! Who knows.
Differential Revision: https://phab.mercurial-scm.org/D5559
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 09 Jan 2019 19:06:15 -0800 |
parents | 536c83535cbd |
children | 6439cefaeb64 |
comparison
equal
deleted
inserted
replaced
41199:d8fe67db5234 | 41200:cecf3f8bccd3 |
---|---|
382 | 382 |
383 # 2-tuple of file handles being used for active writing. | 383 # 2-tuple of file handles being used for active writing. |
384 self._writinghandles = None | 384 self._writinghandles = None |
385 | 385 |
386 mmapindexthreshold = None | 386 mmapindexthreshold = None |
387 v = REVLOG_DEFAULT_VERSION | 387 opts = getattr(opener, 'options', {}) or {} |
388 opts = getattr(opener, 'options', None) | 388 |
389 if opts is not None: | 389 if 'revlogv2' in opts: |
390 if 'revlogv2' in opts: | 390 # version 2 revlogs always use generaldelta. |
391 # version 2 revlogs always use generaldelta. | 391 v = REVLOGV2 | FLAG_GENERALDELTA | FLAG_INLINE_DATA |
392 v = REVLOGV2 | FLAG_GENERALDELTA | FLAG_INLINE_DATA | 392 elif 'revlogv1' in opts: |
393 elif 'revlogv1' in opts: | 393 v = REVLOGV1 | FLAG_INLINE_DATA |
394 if 'generaldelta' in opts: | 394 if 'generaldelta' in opts: |
395 v |= FLAG_GENERALDELTA | 395 v |= FLAG_GENERALDELTA |
396 else: | 396 else: |
397 v = 0 | 397 v = REVLOG_DEFAULT_VERSION |
398 if 'chunkcachesize' in opts: | 398 |
399 self._chunkcachesize = opts['chunkcachesize'] | 399 if 'chunkcachesize' in opts: |
400 if 'maxchainlen' in opts: | 400 self._chunkcachesize = opts['chunkcachesize'] |
401 self._maxchainlen = opts['maxchainlen'] | 401 if 'maxchainlen' in opts: |
402 if 'deltabothparents' in opts: | 402 self._maxchainlen = opts['maxchainlen'] |
403 self._deltabothparents = opts['deltabothparents'] | 403 if 'deltabothparents' in opts: |
404 self._lazydeltabase = bool(opts.get('lazydeltabase', False)) | 404 self._deltabothparents = opts['deltabothparents'] |
405 if 'compengine' in opts: | 405 self._lazydeltabase = bool(opts.get('lazydeltabase', False)) |
406 self._compengine = opts['compengine'] | 406 if 'compengine' in opts: |
407 if 'maxdeltachainspan' in opts: | 407 self._compengine = opts['compengine'] |
408 self._maxdeltachainspan = opts['maxdeltachainspan'] | 408 if 'maxdeltachainspan' in opts: |
409 if mmaplargeindex and 'mmapindexthreshold' in opts: | 409 self._maxdeltachainspan = opts['maxdeltachainspan'] |
410 mmapindexthreshold = opts['mmapindexthreshold'] | 410 if mmaplargeindex and 'mmapindexthreshold' in opts: |
411 self._sparserevlog = bool(opts.get('sparse-revlog', False)) | 411 mmapindexthreshold = opts['mmapindexthreshold'] |
412 withsparseread = bool(opts.get('with-sparse-read', False)) | 412 self._sparserevlog = bool(opts.get('sparse-revlog', False)) |
413 # sparse-revlog forces sparse-read | 413 withsparseread = bool(opts.get('with-sparse-read', False)) |
414 self._withsparseread = self._sparserevlog or withsparseread | 414 # sparse-revlog forces sparse-read |
415 if 'sparse-read-density-threshold' in opts: | 415 self._withsparseread = self._sparserevlog or withsparseread |
416 self._srdensitythreshold = opts['sparse-read-density-threshold'] | 416 if 'sparse-read-density-threshold' in opts: |
417 if 'sparse-read-min-gap-size' in opts: | 417 self._srdensitythreshold = opts['sparse-read-density-threshold'] |
418 self._srmingapsize = opts['sparse-read-min-gap-size'] | 418 if 'sparse-read-min-gap-size' in opts: |
419 if opts.get('enableellipsis'): | 419 self._srmingapsize = opts['sparse-read-min-gap-size'] |
420 self._flagprocessors[REVIDX_ELLIPSIS] = ellipsisprocessor | 420 if opts.get('enableellipsis'): |
421 | 421 self._flagprocessors[REVIDX_ELLIPSIS] = ellipsisprocessor |
422 # revlog v0 doesn't have flag processors | 422 |
423 for flag, processor in opts.get(b'flagprocessors', {}).iteritems(): | 423 # revlog v0 doesn't have flag processors |
424 _insertflagprocessor(flag, processor, self._flagprocessors) | 424 for flag, processor in opts.get(b'flagprocessors', {}).iteritems(): |
425 _insertflagprocessor(flag, processor, self._flagprocessors) | |
425 | 426 |
426 if self._chunkcachesize <= 0: | 427 if self._chunkcachesize <= 0: |
427 raise error.RevlogError(_('revlog chunk cache size %r is not ' | 428 raise error.RevlogError(_('revlog chunk cache size %r is not ' |
428 'greater than 0') % self._chunkcachesize) | 429 'greater than 0') % self._chunkcachesize) |
429 elif self._chunkcachesize & (self._chunkcachesize - 1): | 430 elif self._chunkcachesize & (self._chunkcachesize - 1): |