Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 40267:9d5ddf55415b
revlog: allow flag processors to be applied via store options
This allows flag processors to be registered to specific repos in an extension
by wrapping localrepo.resolverevlogstorevfsoptions(). I wanted to add the
processors via a function on localrepo, but some of the places where the
processors are globally registered don't have a repository available. This
makes targeting specific repos in the wrapper awkward, but still manageable.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 09 Oct 2018 21:53:21 -0400 |
parents | ba70e3acf58a |
children | 9cadb0f5f227 |
comparison
equal
deleted
inserted
replaced
40266:ab04ce6f0674 | 40267:9d5ddf55415b |
---|---|
149 | 149 |
150 Note: The 'raw' transform is used for changegroup generation and in some | 150 Note: The 'raw' transform is used for changegroup generation and in some |
151 debug commands. In this case the transform only indicates whether the | 151 debug commands. In this case the transform only indicates whether the |
152 contents can be used for hash integrity checks. | 152 contents can be used for hash integrity checks. |
153 """ | 153 """ |
154 _insertflagprocessor(flag, processor, _flagprocessors) | |
155 | |
156 def _insertflagprocessor(flag, processor, flagprocessors): | |
154 if not flag & REVIDX_KNOWN_FLAGS: | 157 if not flag & REVIDX_KNOWN_FLAGS: |
155 msg = _("cannot register processor on unknown flag '%#x'.") % (flag) | 158 msg = _("cannot register processor on unknown flag '%#x'.") % (flag) |
156 raise error.ProgrammingError(msg) | 159 raise error.ProgrammingError(msg) |
157 if flag not in REVIDX_FLAGS_ORDER: | 160 if flag not in REVIDX_FLAGS_ORDER: |
158 msg = _("flag '%#x' undefined in REVIDX_FLAGS_ORDER.") % (flag) | 161 msg = _("flag '%#x' undefined in REVIDX_FLAGS_ORDER.") % (flag) |
159 raise error.ProgrammingError(msg) | 162 raise error.ProgrammingError(msg) |
160 if flag in _flagprocessors: | 163 if flag in flagprocessors: |
161 msg = _("cannot register multiple processors on flag '%#x'.") % (flag) | 164 msg = _("cannot register multiple processors on flag '%#x'.") % (flag) |
162 raise error.Abort(msg) | 165 raise error.Abort(msg) |
163 _flagprocessors[flag] = processor | 166 flagprocessors[flag] = processor |
164 | 167 |
165 def getoffset(q): | 168 def getoffset(q): |
166 return int(q >> 16) | 169 return int(q >> 16) |
167 | 170 |
168 def gettype(q): | 171 def gettype(q): |
405 self._srdensitythreshold = opts['sparse-read-density-threshold'] | 408 self._srdensitythreshold = opts['sparse-read-density-threshold'] |
406 if 'sparse-read-min-gap-size' in opts: | 409 if 'sparse-read-min-gap-size' in opts: |
407 self._srmingapsize = opts['sparse-read-min-gap-size'] | 410 self._srmingapsize = opts['sparse-read-min-gap-size'] |
408 if opts.get('enableellipsis'): | 411 if opts.get('enableellipsis'): |
409 self._flagprocessors[REVIDX_ELLIPSIS] = ellipsisprocessor | 412 self._flagprocessors[REVIDX_ELLIPSIS] = ellipsisprocessor |
413 | |
414 # revlog v0 doesn't have flag processors | |
415 for flag, processor in opts.get(b'flagprocessors', {}).iteritems(): | |
416 _insertflagprocessor(flag, processor, self._flagprocessors) | |
410 | 417 |
411 if self._chunkcachesize <= 0: | 418 if self._chunkcachesize <= 0: |
412 raise error.RevlogError(_('revlog chunk cache size %r is not ' | 419 raise error.RevlogError(_('revlog chunk cache size %r is not ' |
413 'greater than 0') % self._chunkcachesize) | 420 'greater than 0') % self._chunkcachesize) |
414 elif self._chunkcachesize & (self._chunkcachesize - 1): | 421 elif self._chunkcachesize & (self._chunkcachesize - 1): |