comparison mercurial/revlog.py @ 42731:5109217a9ab6

flagutil: move insertflagprocessor to the new module (API)
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 08 Aug 2019 01:25:37 +0200
parents 92ac6b1697a7
children 6d61be152c55
comparison
equal deleted inserted replaced
42730:92ac6b1697a7 42731:5109217a9ab6
148 148
149 Note: The 'raw' transform is used for changegroup generation and in some 149 Note: The 'raw' transform is used for changegroup generation and in some
150 debug commands. In this case the transform only indicates whether the 150 debug commands. In this case the transform only indicates whether the
151 contents can be used for hash integrity checks. 151 contents can be used for hash integrity checks.
152 """ 152 """
153 _insertflagprocessor(flag, processor, flagutil.flagprocessors) 153 flagutil.insertflagprocessor(flag, processor, flagutil.flagprocessors)
154
155 def _insertflagprocessor(flag, processor, flagprocessors):
156 if not flag & flagutil.REVIDX_KNOWN_FLAGS:
157 msg = _("cannot register processor on unknown flag '%#x'.") % (flag)
158 raise error.ProgrammingError(msg)
159 if flag not in REVIDX_FLAGS_ORDER:
160 msg = _("flag '%#x' undefined in REVIDX_FLAGS_ORDER.") % (flag)
161 raise error.ProgrammingError(msg)
162 if flag in flagprocessors:
163 msg = _("cannot register multiple processors on flag '%#x'.") % (flag)
164 raise error.Abort(msg)
165 flagprocessors[flag] = processor
166 154
167 def getoffset(q): 155 def getoffset(q):
168 return int(q >> 16) 156 return int(q >> 16)
169 157
170 def gettype(q): 158 def gettype(q):
436 if opts.get('enableellipsis'): 424 if opts.get('enableellipsis'):
437 self._flagprocessors[REVIDX_ELLIPSIS] = ellipsisprocessor 425 self._flagprocessors[REVIDX_ELLIPSIS] = ellipsisprocessor
438 426
439 # revlog v0 doesn't have flag processors 427 # revlog v0 doesn't have flag processors
440 for flag, processor in opts.get(b'flagprocessors', {}).iteritems(): 428 for flag, processor in opts.get(b'flagprocessors', {}).iteritems():
441 _insertflagprocessor(flag, processor, self._flagprocessors) 429 flagutil.insertflagprocessor(flag, processor, self._flagprocessors)
442 430
443 if self._chunkcachesize <= 0: 431 if self._chunkcachesize <= 0:
444 raise error.RevlogError(_('revlog chunk cache size %r is not ' 432 raise error.RevlogError(_('revlog chunk cache size %r is not '
445 'greater than 0') % self._chunkcachesize) 433 'greater than 0') % self._chunkcachesize)
446 elif self._chunkcachesize & (self._chunkcachesize - 1): 434 elif self._chunkcachesize & (self._chunkcachesize - 1):