Mercurial > hg
changeset 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 | d8fe67db5234 |
children | 6439cefaeb64 |
files | mercurial/revlog.py |
diffstat | 1 files changed, 39 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlog.py Wed Jan 09 15:33:44 2019 -0800 +++ b/mercurial/revlog.py Wed Jan 09 19:06:15 2019 -0800 @@ -384,44 +384,45 @@ self._writinghandles = None mmapindexthreshold = None - v = REVLOG_DEFAULT_VERSION - opts = getattr(opener, 'options', None) - if opts is not None: - if 'revlogv2' in opts: - # version 2 revlogs always use generaldelta. - v = REVLOGV2 | FLAG_GENERALDELTA | FLAG_INLINE_DATA - elif 'revlogv1' in opts: - if 'generaldelta' in opts: - v |= FLAG_GENERALDELTA - else: - v = 0 - if 'chunkcachesize' in opts: - self._chunkcachesize = opts['chunkcachesize'] - if 'maxchainlen' in opts: - self._maxchainlen = opts['maxchainlen'] - if 'deltabothparents' in opts: - self._deltabothparents = opts['deltabothparents'] - self._lazydeltabase = bool(opts.get('lazydeltabase', False)) - if 'compengine' in opts: - self._compengine = opts['compengine'] - if 'maxdeltachainspan' in opts: - self._maxdeltachainspan = opts['maxdeltachainspan'] - if mmaplargeindex and 'mmapindexthreshold' in opts: - mmapindexthreshold = opts['mmapindexthreshold'] - self._sparserevlog = bool(opts.get('sparse-revlog', False)) - withsparseread = bool(opts.get('with-sparse-read', False)) - # sparse-revlog forces sparse-read - self._withsparseread = self._sparserevlog or withsparseread - if 'sparse-read-density-threshold' in opts: - self._srdensitythreshold = opts['sparse-read-density-threshold'] - if 'sparse-read-min-gap-size' in opts: - self._srmingapsize = opts['sparse-read-min-gap-size'] - if opts.get('enableellipsis'): - self._flagprocessors[REVIDX_ELLIPSIS] = ellipsisprocessor - - # revlog v0 doesn't have flag processors - for flag, processor in opts.get(b'flagprocessors', {}).iteritems(): - _insertflagprocessor(flag, processor, self._flagprocessors) + opts = getattr(opener, 'options', {}) or {} + + if 'revlogv2' in opts: + # version 2 revlogs always use generaldelta. + v = REVLOGV2 | FLAG_GENERALDELTA | FLAG_INLINE_DATA + elif 'revlogv1' in opts: + v = REVLOGV1 | FLAG_INLINE_DATA + if 'generaldelta' in opts: + v |= FLAG_GENERALDELTA + else: + v = REVLOG_DEFAULT_VERSION + + if 'chunkcachesize' in opts: + self._chunkcachesize = opts['chunkcachesize'] + if 'maxchainlen' in opts: + self._maxchainlen = opts['maxchainlen'] + if 'deltabothparents' in opts: + self._deltabothparents = opts['deltabothparents'] + self._lazydeltabase = bool(opts.get('lazydeltabase', False)) + if 'compengine' in opts: + self._compengine = opts['compengine'] + if 'maxdeltachainspan' in opts: + self._maxdeltachainspan = opts['maxdeltachainspan'] + if mmaplargeindex and 'mmapindexthreshold' in opts: + mmapindexthreshold = opts['mmapindexthreshold'] + self._sparserevlog = bool(opts.get('sparse-revlog', False)) + withsparseread = bool(opts.get('with-sparse-read', False)) + # sparse-revlog forces sparse-read + self._withsparseread = self._sparserevlog or withsparseread + if 'sparse-read-density-threshold' in opts: + self._srdensitythreshold = opts['sparse-read-density-threshold'] + if 'sparse-read-min-gap-size' in opts: + self._srmingapsize = opts['sparse-read-min-gap-size'] + if opts.get('enableellipsis'): + self._flagprocessors[REVIDX_ELLIPSIS] = ellipsisprocessor + + # revlog v0 doesn't have flag processors + for flag, processor in opts.get(b'flagprocessors', {}).iteritems(): + _insertflagprocessor(flag, processor, self._flagprocessors) if self._chunkcachesize <= 0: raise error.RevlogError(_('revlog chunk cache size %r is not '